[Transform] Transforms health alerting rule type (#112277)

This commit is contained in:
Dima Arnautov 2021-10-06 18:27:24 +02:00 committed by GitHub
parent f8611470e6
commit 6da1323ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 1047 additions and 19 deletions

View file

@ -8,6 +8,7 @@
import { i18n } from '@kbn/i18n';
import { LicenseType } from '../../licensing/common/types';
import { TransformHealthTests } from './types/alerting';
export const DEFAULT_REFRESH_INTERVAL_MS = 30000;
export const MINIMUM_REFRESH_INTERVAL_MS = 1000;
@ -108,3 +109,26 @@ export const TRANSFORM_FUNCTION = {
} as const;
export type TransformFunction = typeof TRANSFORM_FUNCTION[keyof typeof TRANSFORM_FUNCTION];
export const TRANSFORM_RULE_TYPE = {
TRANSFORM_HEALTH: 'transform_health',
} as const;
export const ALL_TRANSFORMS_SELECTION = '*';
export const TRANSFORM_HEALTH_CHECK_NAMES: Record<
TransformHealthTests,
{ name: string; description: string }
> = {
notStarted: {
name: i18n.translate('xpack.transform.alertTypes.transformHealth.notStartedCheckName', {
defaultMessage: 'Transform is not started',
}),
description: i18n.translate(
'xpack.transform.alertTypes.transformHealth.notStartedCheckDescription',
{
defaultMessage: 'Get alerts when the transform is not started or is not indexing data.',
}
),
},
};

View file

@ -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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export { TRANSFORM_RULE_TYPE } from './constants';

View file

@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { AlertTypeParams } from '../../../alerting/common';
export type TransformHealthRuleParams = {
includeTransforms?: string[];
excludeTransforms?: string[] | null;
testsConfig?: {
notStarted?: {
enabled: boolean;
} | null;
} | null;
} & AlertTypeParams;
export type TransformHealthRuleTestsConfig = TransformHealthRuleParams['testsConfig'];
export type TransformHealthTests = keyof Exclude<TransformHealthRuleTestsConfig, null | undefined>;

View file

@ -20,3 +20,7 @@ export function dictionaryToArray<TValue>(dict: Dictionary<TValue>): TValue[] {
export type DeepPartial<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};
export function isDefined<T>(argument: T | undefined | null): argument is T {
return argument !== undefined && argument !== null;
}

View file

@ -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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { TransformHealthRuleTestsConfig } from '../types/alerting';
export function getResultTestConfig(config: TransformHealthRuleTestsConfig) {
return {
notStarted: {
enabled: config?.notStarted?.enabled ?? true,
},
};
}