-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Transform] Transforms health alerting rule type #112277
Changes from 11 commits
b7a5e78
22764b1
5528e11
4e893cd
01d4681
ae1f4b4
90b0057
804e98c
fea3b9f
4d38af1
e99df63
6c27a24
25e205d
9b45e6b
4a66cd5
7143506
b7c5e39
8777531
bbad483
2d3db4d
fe295c2
e8ba26e
2f78ca0
5f15ad1
422777a
76ef141
a4f2e28
af04cc9
621f45a
a6d8fe6
c363b2c
de0a7d9
0d5253c
4cbd7d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ import { | |
PluginsStart, | ||
RequestHandlerContextMonitoringPlugin, | ||
} from './types'; | ||
import { getTransformHealthRuleType } from '../../transform/server'; | ||
|
||
// This is used to test the version of kibana | ||
const snapshotRegex = /-snapshot/i; | ||
|
@@ -127,6 +128,8 @@ export class MonitoringPlugin | |
for (const alert of alerts) { | ||
plugins.alerting?.registerType(alert.getRuleType()); | ||
} | ||
plugins.alerting?.registerType(getTransformHealthRuleType()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any specific reason to do not use a factory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed it and realized it's not a right fit for the Stack Monitoring rules. We're going to include it in the Stack Rules instead. |
||
|
||
const config = createConfig(this.initializerContext.config.get<TypeOf<typeof configSchema>>()); | ||
|
||
// Register collector objects for stats to show up in the APIs | ||
|
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'; |
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>; |
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, | ||
}, | ||
}; | ||
} |
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 { createTransformHealthRuleType } from './transform_health_rule_type'; |
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 { createTransformHealthRuleType } from './register_transform_health_rule'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 createTransformHealthRuleType(): AlertTypeModel<TransformHealthRuleParams> { | ||
return { | ||
id: TRANSFORM_RULE_TYPE.TRANSFORM_HEALTH, | ||
description: i18n.translate('xpack.transform.alertingRuleTypes.transformHealth.description', { | ||
defaultMessage: 'Alert when transform jobs experience operational issues.', | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}), | ||
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[]>, | ||
}; | ||
|
||
return validationResult; | ||
}, | ||
requiresAppContext: false, | ||
defaultActionMessage: i18n.translate( | ||
'xpack.transform.alertTypes.transformHealth.defaultActionMessage', | ||
{ | ||
defaultMessage: `[\\{\\{rule.name\\}\\}] Transforms health check result: | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
\\{\\{context.message\\}\\} | ||
\\{\\{#context.results\\}\\} | ||
Transform ID: \\{\\{transform_id\\}\\} | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
\\{\\{#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\\}\\} | ||
`, | ||
} | ||
), | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 React, { FC, useCallback } from 'react'; | ||
import { EuiDescribedFormGroup, EuiForm, EuiFormRow, EuiSpacer, EuiSwitch } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { | ||
TransformHealthRuleTestsConfig, | ||
TransformHealthTests, | ||
} from '../../../common/types/alerting'; | ||
import { getResultTestConfig } from '../../../common/utils/alerts'; | ||
import { TRANSFORM_HEALTH_CHECK_NAMES } from '../../../common/constants'; | ||
|
||
interface TestsSelectionControlProps { | ||
config: TransformHealthRuleTestsConfig; | ||
onChange: (update: TransformHealthRuleTestsConfig) => void; | ||
errors?: string[]; | ||
} | ||
|
||
export const TestsSelectionControl: FC<TestsSelectionControlProps> = React.memo( | ||
({ config, onChange, errors }) => { | ||
const uiConfig = getResultTestConfig(config); | ||
|
||
const updateCallback = useCallback( | ||
(update: Partial<Exclude<TransformHealthRuleTestsConfig, undefined>>) => { | ||
onChange({ | ||
...(config ?? {}), | ||
...update, | ||
}); | ||
}, | ||
[onChange, config] | ||
); | ||
|
||
return ( | ||
<> | ||
<EuiForm component="div" isInvalid={!!errors?.length} error={errors}> | ||
{(Object.entries(uiConfig) as Array< | ||
[TransformHealthTests, typeof uiConfig[TransformHealthTests]] | ||
>).map(([name, conf], i) => { | ||
return ( | ||
<EuiDescribedFormGroup | ||
key={name} | ||
title={<h4>{TRANSFORM_HEALTH_CHECK_NAMES[name]?.name}</h4>} | ||
description={TRANSFORM_HEALTH_CHECK_NAMES[name]?.description} | ||
fullWidth | ||
gutterSize={'s'} | ||
> | ||
<EuiFormRow> | ||
<EuiSwitch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With only one check currently available, is it worth disabling the switch control until the next check is added? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. disabled in darnautov@bbad483 |
||
label={ | ||
<FormattedMessage | ||
id="xpack.transform.alertTypes.transformHealth.testsSelection.enableTestLabel" | ||
defaultMessage="Enable" | ||
/> | ||
} | ||
onChange={updateCallback.bind(null, { | ||
[name]: { | ||
...uiConfig[name], | ||
enabled: !uiConfig[name].enabled, | ||
}, | ||
})} | ||
checked={uiConfig[name].enabled} | ||
/> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
); | ||
})} | ||
</EuiForm> | ||
<EuiSpacer size="l" /> | ||
</> | ||
); | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to address this TODO is the current PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no docs page for it yet, so I'm going to add it in the follow-up PR probably as soon as it's ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darnautov This is the correct link. Docs are available at https://www.elastic.co/guide/en/elasticsearch/reference/master/transform-alerts.html