-
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.
Browse files
Browse the repository at this point in the history
Co-authored-by: Dima Arnautov <[email protected]>
- Loading branch information
1 parent
c6b7e9c
commit 2875113
Showing
34 changed files
with
1,047 additions
and
19 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
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
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,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'; |
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,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>; |
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,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, | ||
}, | ||
}; | ||
} |
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,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 { getTransformHealthRuleType } from './transform_health_rule_type'; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/transform/public/alerting/transform_health_rule_type/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,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 { getTransformHealthRuleType } from './register_transform_health_rule'; |
66 changes: 66 additions & 0 deletions
66
...ns/transform/public/alerting/transform_health_rule_type/register_transform_health_rule.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,66 @@ | ||
/* | ||
* 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 { lazy } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { TRANSFORM_RULE_TYPE } from '../../../common'; | ||
import type { TransformHealthRuleParams } from '../../../common/types/alerting'; | ||
import type { AlertTypeModel } from '../../../../triggers_actions_ui/public'; | ||
|
||
export function getTransformHealthRuleType(): AlertTypeModel<TransformHealthRuleParams> { | ||
return { | ||
id: TRANSFORM_RULE_TYPE.TRANSFORM_HEALTH, | ||
description: i18n.translate('xpack.transform.alertingRuleTypes.transformHealth.description', { | ||
defaultMessage: 'Alert when transforms experience operational issues.', | ||
}), | ||
iconClass: 'bell', | ||
documentationUrl(docLinks) { | ||
return docLinks.links.transforms.alertingRules; | ||
}, | ||
alertParamsExpression: lazy(() => import('./transform_health_rule_trigger')), | ||
validate: (alertParams: TransformHealthRuleParams) => { | ||
const validationResult = { | ||
errors: { | ||
includeTransforms: new Array<string>(), | ||
} as Record<keyof TransformHealthRuleParams, string[]>, | ||
}; | ||
|
||
if (!alertParams.includeTransforms?.length) { | ||
validationResult.errors.includeTransforms?.push( | ||
i18n.translate( | ||
'xpack.transform.alertTypes.transformHealth.includeTransforms.errorMessage', | ||
{ | ||
defaultMessage: 'At least one transform has to be selected', | ||
} | ||
) | ||
); | ||
} | ||
|
||
return validationResult; | ||
}, | ||
requiresAppContext: false, | ||
defaultActionMessage: i18n.translate( | ||
'xpack.transform.alertTypes.transformHealth.defaultActionMessage', | ||
{ | ||
defaultMessage: `[\\{\\{rule.name\\}\\}] Transform health check result: | ||
\\{\\{context.message\\}\\} | ||
\\{\\{#context.results\\}\\} | ||
Transform ID: \\{\\{transform_id\\}\\} | ||
\\{\\{#description\\}\\}Transform description: \\{\\{description\\}\\} | ||
\\{\\{/description\\}\\}\\{\\{#transform_state\\}\\}Transform state: \\{\\{transform_state\\}\\} | ||
\\{\\{/transform_state\\}\\}\\{\\{#failure_reason\\}\\}Failure reason: \\{\\{failure_reason\\}\\} | ||
\\{\\{/failure_reason\\}\\}\\{\\{#notification_message\\}\\}Notification message: \\{\\{notification_message\\}\\} | ||
\\{\\{/notification_message\\}\\}\\{\\{#node_name\\}\\}Node name: \\{\\{node_name\\}\\} | ||
\\{\\{/node_name\\}\\}\\{\\{#timestamp\\}\\}Timestamp: \\{\\{timestamp\\}\\} | ||
\\{\\{/timestamp\\}\\} | ||
\\{\\{/context.results\\}\\} | ||
`, | ||
} | ||
), | ||
}; | ||
} |
Oops, something went wrong.