Add timestamp context variable (#67482)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
56ed61e303
commit
e591aa99d3
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
import { mapValues, first } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import moment from 'moment';
|
||||
import { InfraDatabaseSearchResponse } from '../../adapters/framework/adapter_types';
|
||||
import { createAfterKeyHandler } from '../../../utils/create_afterkey_handler';
|
||||
import { getAllCompositeData } from '../../../utils/get_all_composite_data';
|
||||
|
@ -336,6 +337,7 @@ export const createMetricThresholdExecutor = (libs: InfraBackendLibs, alertId: s
|
|||
group,
|
||||
alertState: stateToAlertMessage[nextState],
|
||||
reason,
|
||||
timestamp: moment().toISOString(),
|
||||
value: mapToConditionsLookup(alertResults, (result) => result[group].currentValue),
|
||||
threshold: mapToConditionsLookup(criteria, (c) => c.threshold),
|
||||
metric: mapToConditionsLookup(criteria, (c) => c.metric),
|
||||
|
|
|
@ -55,6 +55,13 @@ export function registerMetricThresholdAlertType(libs: InfraBackendLibs) {
|
|||
}
|
||||
);
|
||||
|
||||
const timestampActionVariableDescription = i18n.translate(
|
||||
'xpack.infra.metrics.alerting.threshold.alerting.timestampDescription',
|
||||
{
|
||||
defaultMessage: 'A timestamp of when the alert was detected.',
|
||||
}
|
||||
);
|
||||
|
||||
const valueActionVariableDescription = i18n.translate(
|
||||
'xpack.infra.metrics.alerting.threshold.alerting.valueActionVariableDescription',
|
||||
{
|
||||
|
@ -106,6 +113,7 @@ export function registerMetricThresholdAlertType(libs: InfraBackendLibs) {
|
|||
{ name: 'group', description: groupActionVariableDescription },
|
||||
{ name: 'alertState', description: alertStateActionVariableDescription },
|
||||
{ name: 'reason', description: reasonActionVariableDescription },
|
||||
{ name: 'timestamp', description: timestampActionVariableDescription },
|
||||
{ name: 'value', description: valueActionVariableDescription },
|
||||
{ name: 'metric', description: metricActionVariableDescription },
|
||||
{ name: 'threshold', description: thresholdActionVariableDescription },
|
||||
|
|
Loading…
Reference in a new issue