-
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.
Merge branch 'master' into reporting/register-routes-synchro
- Loading branch information
Showing
49 changed files
with
1,825 additions
and
794 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
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,18 @@ | ||
/* | ||
* 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 './types'; | ||
export const INFRA_ALERT_PREVIEW_PATH = '/api/infra/alerting/preview'; | ||
|
||
export const TOO_MANY_BUCKETS_PREVIEW_EXCEPTION = 'TOO_MANY_BUCKETS_PREVIEW_EXCEPTION'; | ||
export interface TooManyBucketsPreviewExceptionMetadata { | ||
TOO_MANY_BUCKETS_PREVIEW_EXCEPTION: any; | ||
maxBuckets: number; | ||
} | ||
export const isTooManyBucketsPreviewException = ( | ||
value: any | ||
): value is TooManyBucketsPreviewExceptionMetadata => | ||
Boolean(value && value.TOO_MANY_BUCKETS_PREVIEW_EXCEPTION); |
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,82 @@ | ||
/* | ||
* 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'; | ||
|
||
// TODO: Have threshold and inventory alerts import these types from this file instead of from their | ||
// local directories | ||
export const METRIC_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.threshold'; | ||
export const METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.inventory.threshold'; | ||
|
||
export enum Comparator { | ||
GT = '>', | ||
LT = '<', | ||
GT_OR_EQ = '>=', | ||
LT_OR_EQ = '<=', | ||
BETWEEN = 'between', | ||
OUTSIDE_RANGE = 'outside', | ||
} | ||
|
||
export enum Aggregators { | ||
COUNT = 'count', | ||
AVERAGE = 'avg', | ||
SUM = 'sum', | ||
MIN = 'min', | ||
MAX = 'max', | ||
RATE = 'rate', | ||
CARDINALITY = 'cardinality', | ||
P95 = 'p95', | ||
P99 = 'p99', | ||
} | ||
|
||
// Alert Preview API | ||
const baseAlertRequestParamsRT = rt.intersection([ | ||
rt.partial({ | ||
filterQuery: rt.union([rt.string, rt.undefined]), | ||
sourceId: rt.string, | ||
}), | ||
rt.type({ | ||
lookback: rt.union([rt.literal('h'), rt.literal('d'), rt.literal('w'), rt.literal('M')]), | ||
criteria: rt.array(rt.any), | ||
alertInterval: rt.string, | ||
}), | ||
]); | ||
|
||
const metricThresholdAlertPreviewRequestParamsRT = rt.intersection([ | ||
baseAlertRequestParamsRT, | ||
rt.partial({ | ||
groupBy: rt.union([rt.string, rt.array(rt.string), rt.undefined]), | ||
}), | ||
rt.type({ | ||
alertType: rt.literal(METRIC_THRESHOLD_ALERT_TYPE_ID), | ||
}), | ||
]); | ||
export type MetricThresholdAlertPreviewRequestParams = rt.TypeOf< | ||
typeof metricThresholdAlertPreviewRequestParamsRT | ||
>; | ||
|
||
const inventoryAlertPreviewRequestParamsRT = rt.intersection([ | ||
baseAlertRequestParamsRT, | ||
rt.type({ | ||
nodeType: rt.string, | ||
alertType: rt.literal(METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID), | ||
}), | ||
]); | ||
|
||
export const alertPreviewRequestParamsRT = rt.union([ | ||
metricThresholdAlertPreviewRequestParamsRT, | ||
inventoryAlertPreviewRequestParamsRT, | ||
]); | ||
|
||
export const alertPreviewSuccessResponsePayloadRT = rt.type({ | ||
numberOfGroups: rt.number, | ||
resultTotals: rt.type({ | ||
fired: rt.number, | ||
noData: rt.number, | ||
error: rt.number, | ||
tooManyBuckets: rt.number, | ||
}), | ||
}); |
Oops, something went wrong.