-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Logs UI] Add ML job status callouts to results page (#47642)
* Amend outer page / panel structure * Remove unused imports * Add anomalies section and overall chart * Add legend * Rename dataSet to partition * Add max bucket anomaly score * Move job and setup status types to common * Move initial job status fetching into page content * Poll for job status on results page * Add table / expanded row charts * Add bucket span text * Add stat section to expanded rows * Amend annotations on overall graph * Add rule to account for EuiFlexItem edge case * Move functions that handle derivations of data to a new file * Tweak data points fetched * Style bars in grey for anomalies charts * Add severity scoring to annotations * Fix default * Remove decimal places from anomaly score representations * Show all partitions and overall anomaly score in annotation tooltip for overall chart * Handle 'unknown' to workaround lack of '' suuport in tables * Add stats section to overall anomalies section * Base x-domain off the series so that certain buckets aren't omitted * Tweak colours and DRY up annotation rendering * Add sorting to table * Add "number of logs" to API results and render in UI stats * Track and render out-of-sync job configurations * Adjust translation labels * Add stopped state callout * Add more callout icons * Fix api integration tests * Use "pretty" numbers for "Number of logs" stats * Improve status message wording * Change recreate job button color back to default * Add toolbar text * Format all y axis values to 3 digits * Remove "Overall anomaly score" and change all wording / calculations to "Max anomaly scores" * Sort anomaly maximum scores for the overall chart tooltip * Remove unused translations * Use white text with badge in toolbar * Factor out a job recreation callout * Replace `filter()[0]` with `find()` call * Amend key * Use Math.round and introduce a formatAnomalyScore helper function * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/index.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/log_rate/index.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Format y-axis of log entry rate chart the same as anomalies charts * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Remove grow prop * Update x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/page_results_content.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/helpers/data_formatters.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/expanded_row.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/index.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/anomalies/index.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/helpers/data_formatters.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/helpers/data_formatters.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/helpers/data_formatters.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/public/pages/logs/analysis/sections/helpers/data_formatters.tsx Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/lib/log_analysis/log_analysis.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/lib/log_analysis/log_analysis.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Update x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts Co-Authored-By: Felix Stürmer <[email protected]> * Change path * Amend property name * Use proper default value argument * Use Kibana dateFormat setting for toolbar formatting * Change logic for calculating severity score categories * Add missing translations * Add interface to top of file * Add no-wrap to tooltip * Use more idomatic code * Use static value for series styles * Move the callouts into the right location * Fix linter warning * Add non-functional ML link button * Fix merge mistake
- Loading branch information
1 parent
9a13f26
commit 197a63b
Showing
21 changed files
with
721 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './log_analysis_job_problem_indicator'; |
29 changes: 29 additions & 0 deletions
29
.../public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import React from 'react'; | ||
|
||
import { RecreateJobCallout } from './recreate_job_callout'; | ||
|
||
export const JobConfigurationOutdatedCallout: React.FC<{ | ||
onRecreateMlJob: () => void; | ||
}> = ({ onRecreateMlJob }) => ( | ||
<RecreateJobCallout title={jobConfigurationOutdatedTitle} onRecreateMlJob={onRecreateMlJob}> | ||
<FormattedMessage | ||
id="xpack.infra.logs.analysis.jobConfigurationOutdatedCalloutMessage" | ||
defaultMessage="The ML job was created using a different source configuration. Recreate the job to apply the current configuration. This removes previously detected anomalies." | ||
/> | ||
</RecreateJobCallout> | ||
); | ||
|
||
const jobConfigurationOutdatedTitle = i18n.translate( | ||
'xpack.infra.logs.analysis.jobConfigurationOutdatedCalloutTitle', | ||
{ | ||
defaultMessage: 'ML job configuration outdated', | ||
} | ||
); |
29 changes: 29 additions & 0 deletions
29
...fra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import React from 'react'; | ||
|
||
import { RecreateJobCallout } from './recreate_job_callout'; | ||
|
||
export const JobDefinitionOutdatedCallout: React.FC<{ | ||
onRecreateMlJob: () => void; | ||
}> = ({ onRecreateMlJob }) => ( | ||
<RecreateJobCallout title={jobDefinitionOutdatedTitle} onRecreateMlJob={onRecreateMlJob}> | ||
<FormattedMessage | ||
id="xpack.infra.logs.analysis.jobDefinitionOutdatedCalloutMessage" | ||
defaultMessage="A newer version of the ML job is available. Recreate the job to deploy the newer version. This removes previously detected anomalies." | ||
/> | ||
</RecreateJobCallout> | ||
); | ||
|
||
const jobDefinitionOutdatedTitle = i18n.translate( | ||
'xpack.infra.logs.analysis.jobDefinitionOutdatedCalloutTitle', | ||
{ | ||
defaultMessage: 'ML job definition outdated', | ||
} | ||
); |
24 changes: 24 additions & 0 deletions
24
...y/plugins/infra/public/components/logging/log_analysis_job_status/job_stopped_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiCallOut } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
export const JobStoppedCallout: React.FC = () => ( | ||
<EuiCallOut color="primary" iconType="pause" title={jobStoppedTitle}> | ||
<FormattedMessage | ||
id="xpack.infra.logs.analysis.jobStoppedCalloutMessage" | ||
defaultMessage="The ML job has been stopped manually or due to a lack of resources. New log entries will not be processed until the job has been restarted." | ||
tagName="p" | ||
/> | ||
</EuiCallOut> | ||
); | ||
|
||
const jobStoppedTitle = i18n.translate('xpack.infra.logs.analysis.jobStoppedCalloutTitle', { | ||
defaultMessage: 'ML job stopped', | ||
}); |
29 changes: 29 additions & 0 deletions
29
.../public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { JobStatus, SetupStatus } from '../../../../common/log_analysis'; | ||
import { JobConfigurationOutdatedCallout } from './job_configuration_outdated_callout'; | ||
import { JobDefinitionOutdatedCallout } from './job_definition_outdated_callout'; | ||
import { JobStoppedCallout } from './job_stopped_callout'; | ||
|
||
export const LogAnalysisJobProblemIndicator: React.FC<{ | ||
jobStatus: JobStatus; | ||
setupStatus: SetupStatus; | ||
onRecreateMlJobForReconfiguration: () => void; | ||
onRecreateMlJobForUpdate: () => void; | ||
}> = ({ jobStatus, setupStatus, onRecreateMlJobForReconfiguration, onRecreateMlJobForUpdate }) => { | ||
if (jobStatus === 'stopped') { | ||
return <JobStoppedCallout />; | ||
} else if (setupStatus === 'skippedButUpdatable') { | ||
return <JobDefinitionOutdatedCallout onRecreateMlJob={onRecreateMlJobForUpdate} />; | ||
} else if (setupStatus === 'skippedButReconfigurable') { | ||
return <JobConfigurationOutdatedCallout onRecreateMlJob={onRecreateMlJobForReconfiguration} />; | ||
} | ||
|
||
return null; // no problem to indicate | ||
}; |
24 changes: 24 additions & 0 deletions
24
.../plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiCallOut, EuiButton } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
export const RecreateJobCallout: React.FC<{ | ||
onRecreateMlJob: () => void; | ||
title?: React.ReactNode; | ||
}> = ({ children, onRecreateMlJob, title }) => ( | ||
<EuiCallOut color="warning" iconType="alert" title={title}> | ||
<p>{children}</p> | ||
<EuiButton color="warning" onClick={onRecreateMlJob}> | ||
<FormattedMessage | ||
id="xpack.infra.logs.analysis.recreateJobButtonLabel" | ||
defaultMessage="Recreate ML job" | ||
/> | ||
</EuiButton> | ||
</EuiCallOut> | ||
); |
16 changes: 16 additions & 0 deletions
16
x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_api_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
|
||
export const jobCustomSettingsRT = rt.partial({ | ||
job_revision: rt.number, | ||
logs_source_config: rt.partial({ | ||
indexPattern: rt.string, | ||
timestampField: rt.string, | ||
bucketSpan: rt.number, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { fold } from 'fp-ts/lib/Either'; | ||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import { identity } from 'fp-ts/lib/function'; | ||
import * as rt from 'io-ts'; | ||
import { kfetch } from 'ui/kfetch'; | ||
|
||
import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; | ||
import { jobCustomSettingsRT } from './ml_api_types'; | ||
|
||
export const callGetMlModuleAPI = async (moduleId: string) => { | ||
const response = await kfetch({ | ||
method: 'GET', | ||
pathname: `/api/ml/modules/get_module/${moduleId}`, | ||
}); | ||
|
||
return pipe( | ||
getMlModuleResponsePayloadRT.decode(response), | ||
fold(throwErrors(createPlainError), identity) | ||
); | ||
}; | ||
|
||
const jobDefinitionRT = rt.type({ | ||
id: rt.string, | ||
config: rt.type({ | ||
custom_settings: jobCustomSettingsRT, | ||
}), | ||
}); | ||
|
||
export type JobDefinition = rt.TypeOf<typeof jobDefinitionRT>; | ||
|
||
const getMlModuleResponsePayloadRT = rt.type({ | ||
id: rt.string, | ||
jobs: rt.array(jobDefinitionRT), | ||
}); | ||
|
||
export type GetMlModuleResponsePayload = rt.TypeOf<typeof getMlModuleResponsePayloadRT>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.