Skip to content
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

[Metrics UI] Anomaly Detection setup flow for Metrics #76787

Merged
merged 33 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
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 Sep 1, 2020
81bc988
Add ability to create ml jobs from inventory
phillipb Sep 4, 2020
e78486c
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 4, 2020
a72af3f
Fix i18n stuff
phillipb Sep 8, 2020
8c774cb
Fix typecheck
phillipb Sep 8, 2020
9e0741c
Merge branch 'master' into metrics-ml-setup
elasticmachine Sep 8, 2020
1d5e0d1
renames jobs, updates datafeeds
blaklaybul Sep 8, 2020
1a6198d
adds allow_no_indices: true for datafeeds
blaklaybul Sep 10, 2020
4836c40
Merge branch 'ml-metrics-integration-modules' into metrics-ml-setup
phillipb Sep 14, 2020
462d8b3
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 15, 2020
29d84fa
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 15, 2020
60ae1bf
Revert "[Metrics UI] Replace Snapshot API with Metrics API (#76253)"
phillipb Sep 15, 2020
5c586c3
Merge branch 'metrics-ml-setup' of github.com:phillipb/kibana into me…
phillipb Sep 16, 2020
92e83bf
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 16, 2020
1e5fb11
Add ability to fetch anomalies
phillipb Sep 16, 2020
fa334c2
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 17, 2020
06e6ce4
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 21, 2020
8ecc8d3
Fix typecheck
phillipb Sep 21, 2020
eeae687
Fix typecheck
phillipb Sep 21, 2020
a3c749e
Fix i18n
phillipb Sep 21, 2020
5804b35
Fix lint, use the right partition field
phillipb Sep 21, 2020
41acc0d
Delete log files
phillipb Sep 21, 2020
9472023
Fix merge
phillipb Sep 21, 2020
605ad95
Fix merge issues
phillipb Sep 21, 2020
bab3ecc
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 21, 2020
0a05e3d
Update name of jobs
phillipb Sep 21, 2020
6db3327
Remove CPU job
phillipb Sep 21, 2020
70f1c9e
[Metrics UI] Replace Snapshot API with Metrics API (#76253)
simianhacker Sep 9, 2020
8752edf
Merge branch 'master' of https://github.com/elastic/kibana into metri…
phillipb Sep 22, 2020
2bae593
Merge branch 'master' into metrics-ml-setup
elasticmachine Sep 22, 2020
3c7ed68
Add links back to ML for anomalies and manage jobs
phillipb Sep 22, 2020
a9999a2
Fix typecheck
phillipb Sep 22, 2020
8d7073f
Remove unecessary validation
phillipb Sep 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion x-pack/plugins/infra/common/http_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export * from './log_entries';
export * from './metrics_explorer';
export * from './metrics_api';
export * from './log_alerts';
export * from './snapshot_api';
phillipb marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions x-pack/plugins/infra/common/http_api/infra_ml/index.ts
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 x-pack/plugins/infra/common/http_api/infra_ml/results/common.ts
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>;
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';
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
>;
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
>;
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
>;
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';
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>;
6 changes: 2 additions & 4 deletions x-pack/plugins/infra/common/http_api/metrics_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const MetricsAPIRequestRT = rt.intersection([
afterKey: rt.union([rt.null, afterKeyObjectRT]),
limit: rt.union([rt.number, rt.null, rt.undefined]),
filters: rt.array(rt.object),
forceInterval: rt.boolean,
phillipb marked this conversation as resolved.
Show resolved Hide resolved
dropLastBucket: rt.boolean,
alignDataToEnd: rt.boolean,
}),
Expand All @@ -58,10 +59,7 @@ export const MetricsAPIRowRT = rt.intersection([
rt.type({
timestamp: rt.number,
}),
rt.record(
rt.string,
rt.union([rt.string, rt.number, rt.null, rt.undefined, rt.array(rt.object)])
),
rt.record(rt.string, rt.union([rt.string, rt.number, rt.null, rt.undefined])),
phillipb marked this conversation as resolved.
Show resolved Hide resolved
]);

export const MetricsAPISeriesRT = rt.intersection([
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/infra/common/http_api/metrics_explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ export const metricsExplorerRowRT = rt.intersection([
rt.type({
timestamp: rt.number,
}),
rt.record(
rt.string,
rt.union([rt.string, rt.number, rt.null, rt.undefined, rt.array(rt.object)])
),
rt.record(rt.string, rt.union([rt.string, rt.number, rt.null, rt.undefined])),
]);

export const metricsExplorerSeriesRT = rt.intersection([
Expand Down
Loading