forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tic#48309) Backports the following commits to 7.x: - [Logs UI] Add ML job status callouts to results page (elastic#47642)
- Loading branch information
1 parent
e51369a
commit 4cd02c2
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.