diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts index a282a742d614..00a1d97dec81 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts @@ -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), diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_alert_type.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_alert_type.ts index 2c98a568d16d..02d9ca3e5f0c 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_alert_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_alert_type.ts @@ -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 },