-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Metrics UI] Anomaly Detection setup flow for Metrics #76787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
3a29942
adds metrics ml integration
blaklaybul 81bc988
Add ability to create ml jobs from inventory
phillipb e78486c
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb a72af3f
Fix i18n stuff
phillipb 8c774cb
Fix typecheck
phillipb 9e0741c
Merge branch 'master' into metrics-ml-setup
elasticmachine 1d5e0d1
renames jobs, updates datafeeds
blaklaybul 1a6198d
adds allow_no_indices: true for datafeeds
blaklaybul 4836c40
Merge branch 'ml-metrics-integration-modules' into metrics-ml-setup
phillipb 462d8b3
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 29d84fa
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 60ae1bf
Revert "[Metrics UI] Replace Snapshot API with Metrics API (#76253)"
phillipb 5c586c3
Merge branch 'metrics-ml-setup' of github.com:phillipb/kibana into me…
phillipb 92e83bf
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 1e5fb11
Add ability to fetch anomalies
phillipb fa334c2
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 06e6ce4
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 8ecc8d3
Fix typecheck
phillipb eeae687
Fix typecheck
phillipb a3c749e
Fix i18n
phillipb 5804b35
Fix lint, use the right partition field
phillipb 41acc0d
Delete log files
phillipb 9472023
Fix merge
phillipb 605ad95
Fix merge issues
phillipb bab3ecc
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 0a05e3d
Update name of jobs
phillipb 6db3327
Remove CPU job
phillipb 70f1c9e
[Metrics UI] Replace Snapshot API with Metrics API (#76253)
simianhacker 8752edf
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb 2bae593
Merge branch 'master' into metrics-ml-setup
elasticmachine 3c7ed68
Add links back to ML for anomalies and manage jobs
phillipb a9999a2
Fix typecheck
phillipb 8d7073f
Remove unecessary validation
phillipb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,8 @@ | ||
| /* | ||
| * 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 './results'; | ||
| export * from './validation'; |
59 changes: 59 additions & 0 deletions
59
x-pack/plugins/infra/common/http_api/infra_ml/results/common.ts
This file contains hidden or 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,59 @@ | ||
| /* | ||
| * 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'; | ||
|
|
||
| // [Sort field value, tiebreaker value] | ||
| export const paginationCursorRT = rt.tuple([ | ||
| rt.union([rt.string, rt.number]), | ||
| rt.union([rt.string, rt.number]), | ||
| ]); | ||
|
|
||
| export type PaginationCursor = rt.TypeOf<typeof paginationCursorRT>; | ||
|
|
||
| export const anomalyTypeRT = rt.keyof({ | ||
| metrics_hosts: null, | ||
| metrics_k8s: null, | ||
| }); | ||
|
|
||
| export type AnomalyType = rt.TypeOf<typeof anomalyTypeRT>; | ||
|
|
||
| const sortOptionsRT = rt.keyof({ | ||
| anomalyScore: null, | ||
| dataset: null, | ||
| startTime: null, | ||
| }); | ||
|
|
||
| const sortDirectionsRT = rt.keyof({ | ||
| asc: null, | ||
| desc: null, | ||
| }); | ||
|
|
||
| const paginationPreviousPageCursorRT = rt.type({ | ||
| searchBefore: paginationCursorRT, | ||
| }); | ||
|
|
||
| const paginationNextPageCursorRT = rt.type({ | ||
| searchAfter: paginationCursorRT, | ||
| }); | ||
|
|
||
| export const paginationRT = rt.intersection([ | ||
| rt.type({ | ||
| pageSize: rt.number, | ||
| }), | ||
| rt.partial({ | ||
| cursor: rt.union([paginationPreviousPageCursorRT, paginationNextPageCursorRT]), | ||
| }), | ||
| ]); | ||
|
|
||
| export type Pagination = rt.TypeOf<typeof paginationRT>; | ||
|
|
||
| export const sortRT = rt.type({ | ||
| field: sortOptionsRT, | ||
| direction: sortDirectionsRT, | ||
| }); | ||
|
|
||
| export type Sort = rt.TypeOf<typeof sortRT>; |
9 changes: 9 additions & 0 deletions
9
x-pack/plugins/infra/common/http_api/infra_ml/results/index.ts
This file contains hidden or 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,9 @@ | ||
| /* | ||
| * 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 './metrics_hosts_anomalies'; | ||
| export * from './metrics_k8s_anomalies'; | ||
| export * from './common'; |
79 changes: 79 additions & 0 deletions
79
x-pack/plugins/infra/common/http_api/infra_ml/results/metrics_hosts_anomalies.ts
This file contains hidden or 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,79 @@ | ||
| /* | ||
| * 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'; | ||
|
|
||
| import { timeRangeRT, routeTimingMetadataRT } from '../../shared'; | ||
| import { anomalyTypeRT, paginationCursorRT, sortRT, paginationRT } from './common'; | ||
|
|
||
| export const INFA_ML_GET_METRICS_HOSTS_ANOMALIES_PATH = | ||
| '/api/infra/infra_ml/results/metrics_hosts_anomalies'; | ||
|
|
||
| const metricsHostAnomalyCommonFieldsRT = rt.type({ | ||
| id: rt.string, | ||
| anomalyScore: rt.number, | ||
| typical: rt.number, | ||
| actual: rt.number, | ||
| type: anomalyTypeRT, | ||
| duration: rt.number, | ||
| startTime: rt.number, | ||
| jobId: rt.string, | ||
| }); | ||
| const metricsHostsAnomalyRT = metricsHostAnomalyCommonFieldsRT; | ||
|
|
||
| export type MetricsHostsAnomaly = rt.TypeOf<typeof metricsHostsAnomalyRT>; | ||
|
|
||
| export const getMetricsHostsAnomaliesSuccessReponsePayloadRT = rt.intersection([ | ||
| rt.type({ | ||
| data: rt.intersection([ | ||
| rt.type({ | ||
| anomalies: rt.array(metricsHostsAnomalyRT), | ||
| // Signifies there are more entries backwards or forwards. If this was a request | ||
| // for a previous page, there are more previous pages, if this was a request for a next page, | ||
| // there are more next pages. | ||
| hasMoreEntries: rt.boolean, | ||
| }), | ||
| rt.partial({ | ||
| paginationCursors: rt.type({ | ||
| // The cursor to use to fetch the previous page | ||
| previousPageCursor: paginationCursorRT, | ||
| // The cursor to use to fetch the next page | ||
| nextPageCursor: paginationCursorRT, | ||
| }), | ||
| }), | ||
| ]), | ||
| }), | ||
| rt.partial({ | ||
| timing: routeTimingMetadataRT, | ||
| }), | ||
| ]); | ||
|
|
||
| export type GetMetricsHostsAnomaliesSuccessResponsePayload = rt.TypeOf< | ||
| typeof getMetricsHostsAnomaliesSuccessReponsePayloadRT | ||
| >; | ||
|
|
||
| export const getMetricsHostsAnomaliesRequestPayloadRT = rt.type({ | ||
| data: rt.intersection([ | ||
| rt.type({ | ||
| // the ID of the source configuration | ||
| sourceId: rt.string, | ||
| // the time range to fetch the log entry anomalies from | ||
| timeRange: timeRangeRT, | ||
| }), | ||
| rt.partial({ | ||
| // Pagination properties | ||
| pagination: paginationRT, | ||
| // Sort properties | ||
| sort: sortRT, | ||
| // // Dataset filters | ||
| // datasets: rt.array(rt.string), | ||
| }), | ||
| ]), | ||
| }); | ||
|
|
||
| export type GetMetricsHostsAnomaliesRequestPayload = rt.TypeOf< | ||
| typeof getMetricsHostsAnomaliesRequestPayloadRT | ||
| >; |
79 changes: 79 additions & 0 deletions
79
x-pack/plugins/infra/common/http_api/infra_ml/results/metrics_k8s_anomalies.ts
This file contains hidden or 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,79 @@ | ||
| /* | ||
| * 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'; | ||
|
|
||
| import { timeRangeRT, routeTimingMetadataRT } from '../../shared'; | ||
| import { paginationCursorRT, anomalyTypeRT, sortRT, paginationRT } from './common'; | ||
|
|
||
| export const INFA_ML_GET_METRICS_K8S_ANOMALIES_PATH = | ||
| '/api/infra/infra_ml/results/metrics_k8s_anomalies'; | ||
|
|
||
| const metricsK8sAnomalyCommonFieldsRT = rt.type({ | ||
| id: rt.string, | ||
| anomalyScore: rt.number, | ||
| typical: rt.number, | ||
| actual: rt.number, | ||
| type: anomalyTypeRT, | ||
| duration: rt.number, | ||
| startTime: rt.number, | ||
| jobId: rt.string, | ||
| }); | ||
| const metricsK8sAnomalyRT = metricsK8sAnomalyCommonFieldsRT; | ||
|
|
||
| export type MetricsK8sAnomaly = rt.TypeOf<typeof metricsK8sAnomalyRT>; | ||
|
|
||
| export const getMetricsK8sAnomaliesSuccessReponsePayloadRT = rt.intersection([ | ||
| rt.type({ | ||
| data: rt.intersection([ | ||
| rt.type({ | ||
| anomalies: rt.array(metricsK8sAnomalyRT), | ||
| // Signifies there are more entries backwards or forwards. If this was a request | ||
| // for a previous page, there are more previous pages, if this was a request for a next page, | ||
| // there are more next pages. | ||
| hasMoreEntries: rt.boolean, | ||
| }), | ||
| rt.partial({ | ||
| paginationCursors: rt.type({ | ||
| // The cursor to use to fetch the previous page | ||
| previousPageCursor: paginationCursorRT, | ||
| // The cursor to use to fetch the next page | ||
| nextPageCursor: paginationCursorRT, | ||
| }), | ||
| }), | ||
| ]), | ||
| }), | ||
| rt.partial({ | ||
| timing: routeTimingMetadataRT, | ||
| }), | ||
| ]); | ||
|
|
||
| export type GetMetricsK8sAnomaliesSuccessResponsePayload = rt.TypeOf< | ||
| typeof getMetricsK8sAnomaliesSuccessReponsePayloadRT | ||
| >; | ||
|
|
||
| export const getMetricsK8sAnomaliesRequestPayloadRT = rt.type({ | ||
| data: rt.intersection([ | ||
| rt.type({ | ||
| // the ID of the source configuration | ||
| sourceId: rt.string, | ||
| // the time range to fetch the log entry anomalies from | ||
| timeRange: timeRangeRT, | ||
| }), | ||
| rt.partial({ | ||
| // Pagination properties | ||
| pagination: paginationRT, | ||
| // Sort properties | ||
| sort: sortRT, | ||
| // Dataset filters | ||
| datasets: rt.array(rt.string), | ||
| }), | ||
| ]), | ||
| }); | ||
|
|
||
| export type GetMetricsK8sAnomaliesRequestPayload = rt.TypeOf< | ||
| typeof getMetricsK8sAnomaliesRequestPayloadRT | ||
| >; |
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/infra/common/http_api/infra_ml/validation/datasets.ts
This file contains hidden or 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,44 @@ | ||
| /* | ||
| * 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 LOG_ANALYSIS_VALIDATE_DATASETS_PATH = | ||
| '/api/infra/log_analysis/validation/log_entry_datasets'; | ||
|
|
||
| /** | ||
| * Request types | ||
| */ | ||
| export const validateLogEntryDatasetsRequestPayloadRT = rt.type({ | ||
| data: rt.type({ | ||
| indices: rt.array(rt.string), | ||
| timestampField: rt.string, | ||
| startTime: rt.number, | ||
| endTime: rt.number, | ||
| }), | ||
| }); | ||
|
|
||
| export type ValidateLogEntryDatasetsRequestPayload = rt.TypeOf< | ||
| typeof validateLogEntryDatasetsRequestPayloadRT | ||
| >; | ||
|
|
||
| /** | ||
| * Response types | ||
| * */ | ||
| const logEntryDatasetsEntryRT = rt.strict({ | ||
| indexName: rt.string, | ||
| datasets: rt.array(rt.string), | ||
| }); | ||
|
|
||
| export const validateLogEntryDatasetsResponsePayloadRT = rt.type({ | ||
| data: rt.type({ | ||
| datasets: rt.array(logEntryDatasetsEntryRT), | ||
| }), | ||
| }); | ||
|
|
||
| export type ValidateLogEntryDatasetsResponsePayload = rt.TypeOf< | ||
| typeof validateLogEntryDatasetsResponsePayloadRT | ||
| >; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/infra/common/http_api/infra_ml/validation/index.ts
This file contains hidden or 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,8 @@ | ||
| /* | ||
| * 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 './datasets'; | ||
| export * from './log_entry_rate_indices'; |
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/infra/common/http_api/infra_ml/validation/log_entry_rate_indices.ts
This file contains hidden or 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,61 @@ | ||
| /* | ||
| * 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 LOG_ANALYSIS_VALIDATE_INDICES_PATH = | ||
| '/api/infra/log_analysis/validation/log_entry_rate_indices'; | ||
|
|
||
| /** | ||
| * Request types | ||
| */ | ||
| export const validationIndicesFieldSpecificationRT = rt.type({ | ||
| name: rt.string, | ||
| validTypes: rt.array(rt.string), | ||
| }); | ||
|
|
||
| export type ValidationIndicesFieldSpecification = rt.TypeOf< | ||
| typeof validationIndicesFieldSpecificationRT | ||
| >; | ||
|
|
||
| export const validationIndicesRequestPayloadRT = rt.type({ | ||
| data: rt.type({ | ||
| fields: rt.array(validationIndicesFieldSpecificationRT), | ||
| indices: rt.array(rt.string), | ||
| }), | ||
| }); | ||
|
|
||
| export type ValidationIndicesRequestPayload = rt.TypeOf<typeof validationIndicesRequestPayloadRT>; | ||
|
|
||
| /** | ||
| * Response types | ||
| * */ | ||
| export const validationIndicesErrorRT = rt.union([ | ||
| rt.type({ | ||
| error: rt.literal('INDEX_NOT_FOUND'), | ||
| index: rt.string, | ||
| }), | ||
| rt.type({ | ||
| error: rt.literal('FIELD_NOT_FOUND'), | ||
| index: rt.string, | ||
| field: rt.string, | ||
| }), | ||
| rt.type({ | ||
| error: rt.literal('FIELD_NOT_VALID'), | ||
| index: rt.string, | ||
| field: rt.string, | ||
| }), | ||
| ]); | ||
|
|
||
| export type ValidationIndicesError = rt.TypeOf<typeof validationIndicesErrorRT>; | ||
|
|
||
| export const validationIndicesResponsePayloadRT = rt.type({ | ||
| data: rt.type({ | ||
| errors: rt.array(validationIndicesErrorRT), | ||
| }), | ||
| }); | ||
|
|
||
| export type ValidationIndicesResponsePayload = rt.TypeOf<typeof validationIndicesResponsePayloadRT>; |
This file contains hidden or 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
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.