Skip to content

Commit

Permalink
[ML] Data frames: Updated stats structure. (#42923) (#43002)
Browse files Browse the repository at this point in the history
* Reflects the changes to transform stats on the ES side in elastic/elasticsearch#45276
* Updated mock __mocks__/data_frame_transform_list_row.json to reflect the new stats structure
* Previously there were stats attributes task_state and indexer_state, now there is only state.
* Renamed DATA_FRAME_TASK_STATE to DATA_FRAME_TRANSFORM_STATE .
* Extended possible states to aborting, failed, indexing, started, stopped, stopping.
* A stopped batch transform's stats no longer returns the progress until it was stopped. Instead of falling back and showing 0% with an empty progress bar, nothing will be shown. If the job is continued and returns progress again, the progress bar will also be shown again.
* The expanded row's details tab now exposes hard-coded stats/state attributes instead of inferring attributes dynamically from objects. This was done so we can do custom formatting for date fields for example.
  • Loading branch information
walterra authored Aug 9, 2019
1 parent ec10938 commit c8548e0
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
{
"config": {
"id": "fq_date_histogram_1m_1441",
"source": { "index": ["farequote-2019"], "query": { "match_all": {} } },
"dest": { "index": "fq_date_histogram_1m_1441" },
"source": {
"index": [
"farequote-2019"
],
"query": {
"match_all": { }
}
},
"dest": {
"index": "fq_date_histogram_1m_1441"
},
"pivot": {
"group_by": {
"@timestamp": {
"date_histogram": { "field": "@timestamp", "calendar_interval": "1m" }
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "1m"
}
}
},
"aggregations": { "responsetime.avg": { "avg": { "field": "responsetime" } } }
"aggregations": {
"responsetime.avg": {
"avg": {
"field": "responsetime"
}
}
}
},
"version": "8.0.0",
"create_time": 1564388146667,
"mode": "batch"
"create_time": 1564388146667
},
"id": "fq_date_histogram_1m_1441",
"checkpointing": {
"last": {
"checkpoint": 1,
"timestamp_millis": 1564388281199
},
"next": {
"checkpoint": 2,
"indexer_state": "stopped",
"checkpoint_progress": {
"total_docs": 86274,
"docs_remaining": 0,
"percent_complete": 100
}
},
"operations_behind": 0
},
"mode": "batch",
"stats": {
"id": "fq_date_histogram_1m_1441",
"task_state": "stopped",
"state": "stopped",
"stats": {
"pages_processed": 16,
"documents_processed": 86274,
Expand All @@ -52,15 +61,6 @@
"checkpoint": 1,
"timestamp_millis": 1564388281199
},
"next": {
"checkpoint": 2,
"indexer_state": "stopped",
"checkpoint_progress": {
"total_docs": 86274,
"docs_remaining": 0,
"percent_complete": 100
}
},
"operations_behind": 0
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import {
createPermissionFailureMessage,
} from '../../../../../privilege/check_privilege';

import { DataFrameTransformListRow, DATA_FRAME_TASK_STATE } from './common';
import { DataFrameTransformListRow, DATA_FRAME_TRANSFORM_STATE } from './common';

interface DeleteActionProps {
item: DataFrameTransformListRow;
}

export const DeleteAction: SFC<DeleteActionProps> = ({ item }) => {
const disabled = item.stats.task_state === DATA_FRAME_TASK_STATE.STARTED;
const disabled = item.stats.state !== DATA_FRAME_TRANSFORM_STATE.STOPPED;

const canDeleteDataFrame: boolean = checkPermission('canDeleteDataFrame');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
createPermissionFailureMessage,
} from '../../../../../privilege/check_privilege';

import { DataFrameTransformListRow, DATA_FRAME_TASK_STATE } from './common';
import { DataFrameTransformListRow, DATA_FRAME_TRANSFORM_STATE } from './common';
import { stopTransform } from '../../services/transform_service';

import { StartAction } from './action_start';
Expand All @@ -26,7 +26,7 @@ export const getActions = () => {
{
isPrimary: true,
render: (item: DataFrameTransformListRow) => {
if (item.stats.task_state !== DATA_FRAME_TASK_STATE.STARTED) {
if (item.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED) {
return <StartAction item={item} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ import {
import { DataFrameTransformId } from '../../../../common';
import {
getTransformProgress,
DATA_FRAME_TASK_STATE,
DATA_FRAME_TRANSFORM_STATE,
DataFrameTransformListColumn,
DataFrameTransformListRow,
DataFrameTransformStats,
} from './common';
import { getActions } from './actions';

enum TASK_STATE_COLOR {
enum STATE_COLOR {
aborting = 'warning',
failed = 'danger',
indexing = 'primary',
started = 'primary',
stopped = 'hollow',
stopping = 'hollow',
}

export const getTaskStateBadge = (
state: DataFrameTransformStats['task_state'],
state: DataFrameTransformStats['state'],
reason?: DataFrameTransformStats['reason']
) => {
const color = TASK_STATE_COLOR[state];
const color = STATE_COLOR[state];

if (state === DATA_FRAME_TASK_STATE.FAILED && reason !== undefined) {
if (state === DATA_FRAME_TRANSFORM_STATE.FAILED && reason !== undefined) {
return (
<EuiToolTip content={reason}>
<EuiBadge className="mlTaskStateBadge" color={color}>
Expand Down Expand Up @@ -126,10 +129,10 @@ export const getColumns = (
},
{
name: i18n.translate('xpack.ml.dataframe.status', { defaultMessage: 'Status' }),
sortable: (item: DataFrameTransformListRow) => item.stats.task_state,
sortable: (item: DataFrameTransformListRow) => item.stats.state,
truncateText: true,
render(item: DataFrameTransformListRow) {
return getTaskStateBadge(item.stats.task_state, item.stats.reason);
return getTaskStateBadge(item.stats.state, item.stats.reason);
},
width: '100px',
},
Expand All @@ -146,13 +149,17 @@ export const getColumns = (
},
{
name: i18n.translate('xpack.ml.dataframe.progress', { defaultMessage: 'Progress' }),
sortable: getTransformProgress,
sortable: getTransformProgress || 0,
truncateText: true,
render(item: DataFrameTransformListRow) {
const progress = getTransformProgress(item);

const isBatchTransform = typeof item.config.sync === 'undefined';

if (progress === undefined && isBatchTransform === true) {
return null;
}

return (
<EuiFlexGroup alignItems="center" gutterSize="xs">
{isBatchTransform && (
Expand All @@ -170,10 +177,14 @@ export const getColumns = (
{!isBatchTransform && (
<Fragment>
<EuiFlexItem style={{ width: '40px' }} grow={false}>
{item.stats.task_state === DATA_FRAME_TASK_STATE.STARTED && (
<EuiProgress color="primary" size="m" />
)}
{item.stats.task_state === DATA_FRAME_TASK_STATE.STOPPED && (
{/* If not stopped or failed show the animated progress bar */}
{item.stats.state !== DATA_FRAME_TRANSFORM_STATE.STOPPED &&
item.stats.state !== DATA_FRAME_TRANSFORM_STATE.FAILED && (
<EuiProgress color="primary" size="m" />
)}
{/* If stopped or failed show an empty (0%) progress bar */}
{(item.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED ||
item.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED) && (
<EuiProgress value={0} max={100} color="primary" size="m" />
)}
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import mockDataFrameTransformListRow from './__mocks__/data_frame_transform_list
import {
DataFrameTransformListRow,
isCompletedBatchTransform,
DATA_FRAME_TASK_STATE,
DATA_FRAME_TRANSFORM_STATE,
} from './common';

describe('Data Frame: isCompletedBatchTransform()', () => {
Expand All @@ -20,7 +20,7 @@ describe('Data Frame: isCompletedBatchTransform()', () => {
const row = mockDataFrameTransformListRow as DataFrameTransformListRow;
expect(row.stats.checkpointing.last.checkpoint === 1).toBe(true);
expect(row.config.sync === undefined).toBe(true);
expect(row.stats.task_state === DATA_FRAME_TASK_STATE.STOPPED).toBe(true);
expect(row.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED).toBe(true);
expect(isCompletedBatchTransform(mockDataFrameTransformListRow)).toBe(true);

// adapt the mock config to resemble a non-completed transform.
Expand Down
Loading

0 comments on commit c8548e0

Please sign in to comment.