-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Added defaultActionMessage to index threshold alert UI type definition
#80936
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
Changes from 4 commits
a012543
8a50c7f
c5808a0
5d3b8be
10cf1ec
e00826b
86c0e5b
4cc33bc
18c0da9
7fe16cd
9c931be
eb2b0c7
5830f13
31f50e6
ebb3fee
a519a6d
b42992a
a137daf
40a7093
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 |
|---|---|---|
|
|
@@ -83,6 +83,20 @@ export function getAlertType(service: Service): AlertType<Params, {}, {}, Action | |
| } | ||
| ); | ||
|
|
||
| const actionVariableContextFunctionLabel = i18n.translate( | ||
| 'xpack.stackAlerts.indexThreshold.actionVariableContextFunctionLabel', | ||
| { | ||
| defaultMessage: 'A string formatted values combining threshold comparator and threshold', | ||
| } | ||
| ); | ||
|
|
||
| const actionVariableContextWindowLabel = i18n.translate( | ||
| 'xpack.stackAlerts.indexThreshold.actionVariableContextWindowLabel', | ||
| { | ||
| defaultMessage: 'A string formatted values combining time window size and time window unit', | ||
|
||
| } | ||
| ); | ||
|
|
||
| const alertParamsVariables = Object.keys(CoreQueryParamsSchemaProperties).map( | ||
| (propKey: string) => { | ||
| return { | ||
|
|
@@ -107,6 +121,8 @@ export function getAlertType(service: Service): AlertType<Params, {}, {}, Action | |
| { name: 'group', description: actionVariableContextGroupLabel }, | ||
| { name: 'date', description: actionVariableContextDateLabel }, | ||
| { name: 'value', description: actionVariableContextValueLabel }, | ||
| { name: 'function', description: actionVariableContextFunctionLabel }, | ||
| { name: 'window', description: actionVariableContextWindowLabel }, | ||
| ], | ||
| params: [ | ||
| { name: 'threshold', description: actionVariableContextThresholdLabel }, | ||
|
|
@@ -160,10 +176,17 @@ export function getAlertType(service: Service): AlertType<Params, {}, {}, Action | |
|
|
||
| if (!met) continue; | ||
|
|
||
| const agg = params.aggField ? `${params.aggType}(${params.aggField})` : `${params.aggType}`; | ||
| const humanFn = `${agg} ${params.thresholdComparator} ${params.threshold.join(',')}`; | ||
|
|
||
| const window = `${params.timeWindowSize}${params.timeWindowUnit}`; | ||
|
|
||
| const baseContext: BaseActionContext = { | ||
| date, | ||
| group: instanceId, | ||
| value, | ||
| function: humanFn, | ||
| window, | ||
| }; | ||
| const actionContext = addMessages(options, baseContext, params); | ||
| const alertInstance = options.services.alertInstanceFactory(instanceId); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { lazy } from 'react'; | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import { AlertTypeModel } from '../../../../types'; | ||
| import { validateExpression } from './validation'; | ||
| import { IndexThresholdAlertParams } from './types'; | ||
|
|
@@ -17,6 +17,12 @@ export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams, Alerts | |
| iconClass: 'alert', | ||
| alertParamsExpression: lazy(() => import('./expression')), | ||
| validate: validateExpression, | ||
| defaultActionMessage: i18n.translate( | ||
| 'xpack.triggersActionsUI.builtin_alert_types.threshold.alertDefaultActionMessage', | ||
|
||
| { | ||
| defaultMessage: `alert \\{\\{alertName\\}\\} group \\{\\{context.group\\}\\} value \\{\\{context.value\\}\\} exceeded threshold \\{\\{context.function\\}\\} over \\{\\{context.window\\}\\} on \\{\\{context.date\\}\\}`, | ||
| } | ||
| ), | ||
| requiresAppContext: false, | ||
| }; | ||
| } | ||
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.