From 807c5d90f2f670032e43d62f5cc1b62c0ef7ac69 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Wed, 14 Jun 2023 20:21:20 +0200 Subject: [PATCH] [AO] Update default action and recovery messages for observability rule types (#159571) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #157284, closes #158437 ## Summary This PR updates the default action and recovery message for observability rule types. Only uptime is excluded in this PR, I will add that after synching with the synthetics team. [Here](https://docs.google.com/spreadsheets/d/15cJanv0xi4EKo1QZVXsi_NcFcPa_VQze3nQc4P8GZrQ/edit?pli=1#gid=0) you can find the list of default messages and the new proposals. ![image](https://github.com/elastic/kibana/assets/12370520/4f36e971-d8c2-47a9-ac25-9cae567db774) ## 🧪 How to test - Ensure that `server.publicBaseUrl` is configured in kibana.dev.yml - Create an observability rule with an action such as Email to use the default messages (both for alert and recover states) - After an alert is triggered, check the generated action message, it should - match the message mentioned in the list - contain an alert details link pointing to the Alerts page filtered for that specific alert --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- packages/kbn-optimizer/limits.yml | 2 +- .../common/rules/default_action_message.ts | 111 ++++++++++++++++-- .../rule_types/register_apm_rule_types.ts | 8 ++ .../server/routes/alerts/action_variables.ts | 5 +- .../infra/public/alerting/inventory/index.ts | 42 +++++-- .../log_threshold/log_threshold_rule_type.tsx | 32 ++++- .../public/alerting/metric_threshold/index.ts | 42 +++++-- .../server/lib/alerting/common/messages.ts | 5 +- .../register_log_threshold_rule_type.ts | 3 +- .../plugins/infra/server/lib/infra_types.ts | 2 - x-pack/plugins/infra/server/plugin.ts | 1 - .../register_observability_rule_types.ts | 48 ++++++-- .../server/lib/rules/threshold/messages.ts | 5 +- .../lib/alerts/action_variables.ts | 5 +- .../translations/translations/fr-FR.json | 1 - .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - .../alerts/error_count_threshold.spec.ts | 15 ++- 18 files changed, 252 insertions(+), 77 deletions(-) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index c389287ad4da6..58441b7e54bf4 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -95,7 +95,7 @@ pageLoadAssetSize: monitoring: 80000 navigation: 37269 newsfeed: 42228 - observability: 105500 + observability: 115443 observabilityOnboarding: 19573 observabilityShared: 52256 osquery: 107090 diff --git a/x-pack/plugins/apm/common/rules/default_action_message.ts b/x-pack/plugins/apm/common/rules/default_action_message.ts index e8bde279f55ee..52efad33419f7 100644 --- a/x-pack/plugins/apm/common/rules/default_action_message.ts +++ b/x-pack/plugins/apm/common/rules/default_action_message.ts @@ -10,52 +10,139 @@ import { i18n } from '@kbn/i18n'; export const errorCountMessage = i18n.translate( 'xpack.apm.alertTypes.errorCount.defaultActionMessage', { - defaultMessage: `\\{\\{alertName\\}\\} alert is firing because of the following conditions: + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: - Service name: \\{\\{context.serviceName\\}\\} - Environment: \\{\\{context.environment\\}\\} +- Error count: \\{\\{context.triggerValue\\}\\} errors over the last \\{\\{context.interval\\}\\} - Threshold: \\{\\{context.threshold\\}\\} -- Triggered value: \\{\\{context.triggerValue\\}\\} errors over the last \\{\\{context.interval\\}\\}`, + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +export const errorCountRecoveryMessage = i18n.translate( + 'xpack.apm.alertTypes.errorCount.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} has recovered. + +- Service name: \\{\\{context.serviceName\\}\\} +- Environment: \\{\\{context.environment\\}\\} +- Error count: \\{\\{context.triggerValue\\}\\} errors over the last \\{\\{context.interval\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, } ); export const transactionDurationMessage = i18n.translate( 'xpack.apm.alertTypes.transactionDuration.defaultActionMessage', { - defaultMessage: `\\{\\{alertName\\}\\} alert is firing because of the following conditions: + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: - Service name: \\{\\{context.serviceName\\}\\} - Transaction type: \\{\\{context.transactionType\\}\\} - Transaction name: \\{\\{context.transactionName\\}\\} - Environment: \\{\\{context.environment\\}\\} -- Latency threshold: \\{\\{context.threshold\\}\\}ms -- Latency observed: \\{\\{context.triggerValue\\}\\} over the last \\{\\{context.interval\\}\\}`, +- Latency: \\{\\{context.triggerValue\\}\\} over the last \\{\\{context.interval\\}\\} +- Threshold: \\{\\{context.threshold\\}\\}ms + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +export const transactionDurationRecoveryMessage = i18n.translate( + 'xpack.apm.alertTypes.transactionDuration.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} has recovered. + +- Service name: \\{\\{context.serviceName\\}\\} +- Transaction type: \\{\\{context.transactionType\\}\\} +- Transaction name: \\{\\{context.transactionName\\}\\} +- Environment: \\{\\{context.environment\\}\\} +- Latency: \\{\\{context.triggerValue\\}\\} over the last \\{\\{context.interval\\}\\} +- Threshold: \\{\\{context.threshold\\}\\}ms + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, } ); export const transactionErrorRateMessage = i18n.translate( 'xpack.apm.alertTypes.transactionErrorRate.defaultActionMessage', { - defaultMessage: `\\{\\{alertName\\}\\} alert is firing because of the following conditions: + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: - Service name: \\{\\{context.serviceName\\}\\} -- Type: \\{\\{context.transactionType\\}\\} +- Transaction type: \\{\\{context.transactionType\\}\\} - Environment: \\{\\{context.environment\\}\\} +- Failed transaction rate: \\{\\{context.triggerValue\\}\\}% of errors over the last \\{\\{context.interval\\}\\} - Threshold: \\{\\{context.threshold\\}\\}% -- Triggered value: \\{\\{context.triggerValue\\}\\}% of errors over the last \\{\\{context.interval\\}\\}`, + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +export const transactionErrorRateRecoveryMessage = i18n.translate( + 'xpack.apm.alertTypes.transactionErrorRate.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} has recovered. + +- Service name: \\{\\{context.serviceName\\}\\} +- Transaction type: \\{\\{context.transactionType\\}\\} +- Environment: \\{\\{context.environment\\}\\} +- Failed transaction rate: \\{\\{context.triggerValue\\}\\}% of errors over the last \\{\\{context.interval\\}\\} +- Threshold: \\{\\{context.threshold\\}\\}% + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, } ); export const anomalyMessage = i18n.translate( 'xpack.apm.alertTypes.transactionDurationAnomaly.defaultActionMessage', { - defaultMessage: `\\{\\{alertName\\}\\} alert is firing because of the following conditions: + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: + +- Service name: \\{\\{context.serviceName\\}\\} +- Transaction type: \\{\\{context.transactionType\\}\\} +- Environment: \\{\\{context.environment\\}\\} +- Severity: \\{\\{context.triggerValue\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +export const anomalyRecoveryMessage = i18n.translate( + 'xpack.apm.alertTypes.transactionDurationAnomaly.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} has recovered. - Service name: \\{\\{context.serviceName\\}\\} -- Type: \\{\\{context.transactionType\\}\\} +- Transaction type: \\{\\{context.transactionType\\}\\} - Environment: \\{\\{context.environment\\}\\} -- Severity threshold: \\{\\{context.threshold\\}\\} -- Severity value: \\{\\{context.triggerValue\\}\\} +- Severity: \\{\\{context.triggerValue\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) `, } ); diff --git a/x-pack/plugins/apm/public/components/alerting/rule_types/register_apm_rule_types.ts b/x-pack/plugins/apm/public/components/alerting/rule_types/register_apm_rule_types.ts index 7940a4128d809..48069b0a8fa57 100644 --- a/x-pack/plugins/apm/public/components/alerting/rule_types/register_apm_rule_types.ts +++ b/x-pack/plugins/apm/public/components/alerting/rule_types/register_apm_rule_types.ts @@ -16,9 +16,13 @@ import { import { ApmRuleType } from '../../../../common/rules/apm_rule_types'; import { anomalyMessage, + anomalyRecoveryMessage, errorCountMessage, + errorCountRecoveryMessage, transactionDurationMessage, + transactionDurationRecoveryMessage, transactionErrorRateMessage, + transactionErrorRateRecoveryMessage, } from '../../../../common/rules/default_action_message'; // copied from elasticsearch_fieldnames.ts to limit page load bundle size @@ -55,6 +59,7 @@ export function registerApmRuleTypes( }), requiresAppContext: false, defaultActionMessage: errorCountMessage, + defaultRecoveryMessage: errorCountRecoveryMessage, }); observabilityRuleTypeRegistry.register({ @@ -92,6 +97,7 @@ export function registerApmRuleTypes( ), requiresAppContext: false, defaultActionMessage: transactionDurationMessage, + defaultRecoveryMessage: transactionDurationRecoveryMessage, }); observabilityRuleTypeRegistry.register({ @@ -124,6 +130,7 @@ export function registerApmRuleTypes( }), requiresAppContext: false, defaultActionMessage: transactionErrorRateMessage, + defaultRecoveryMessage: transactionErrorRateRecoveryMessage, }); observabilityRuleTypeRegistry.register({ @@ -153,5 +160,6 @@ export function registerApmRuleTypes( }), requiresAppContext: false, defaultActionMessage: anomalyMessage, + defaultRecoveryMessage: anomalyRecoveryMessage, }); } diff --git a/x-pack/plugins/apm/server/routes/alerts/action_variables.ts b/x-pack/plugins/apm/server/routes/alerts/action_variables.ts index 1bb9c41546cf8..c911aa674631f 100644 --- a/x-pack/plugins/apm/server/routes/alerts/action_variables.ts +++ b/x-pack/plugins/apm/server/routes/alerts/action_variables.ts @@ -13,7 +13,7 @@ export const apmActionVariables = { 'xpack.apm.alerts.action_variables.alertDetailsUrl', { defaultMessage: - 'Link to the view within Elastic that shows further details and context surrounding this alert', + 'Link to the alert troubleshooting view for further context and details. This will be an empty string if the server.publicBaseUrl is not configured.', } ), name: 'alertDetailsUrl' as const, @@ -87,8 +87,7 @@ export const apmActionVariables = { description: i18n.translate( 'xpack.apm.alerts.action_variables.viewInAppUrl', { - defaultMessage: - 'Link to the view or feature within Elastic that can be used to investigate the alert and its context further', + defaultMessage: 'Link to the alert source', } ), name: 'viewInAppUrl' as const, diff --git a/x-pack/plugins/infra/public/alerting/inventory/index.ts b/x-pack/plugins/infra/public/alerting/inventory/index.ts index c9b825340496a..b25eaba2ba3a6 100644 --- a/x-pack/plugins/infra/public/alerting/inventory/index.ts +++ b/x-pack/plugins/infra/public/alerting/inventory/index.ts @@ -20,6 +20,36 @@ interface InventoryMetricRuleTypeParams extends RuleTypeParams { criteria: InventoryMetricConditions[]; } +const inventoryDefaultActionMessage = i18n.translate( + 'xpack.infra.metrics.alerting.inventory.threshold.defaultActionMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: + +- Affected: \\{\\{context.group\\}\\} +- Metric: \\{\\{context.metric\\}\\} +- Observed value: \\{\\{context.value\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +const inventoryDefaultRecoveryMessage = i18n.translate( + 'xpack.infra.metrics.alerting.inventory.threshold.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{rule.name\\}\\} has recovered. + +- Affected: \\{\\{context.group\\}\\} +- Metric: \\{\\{context.metric\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); + export function createInventoryMetricRuleType(): ObservabilityRuleTypeModel { return { id: METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID, @@ -32,16 +62,8 @@ export function createInventoryMetricRuleType(): ObservabilityRuleTypeModel import('./components/expression')), validate: validateMetricThreshold, - defaultActionMessage: i18n.translate( - 'xpack.infra.metrics.alerting.inventory.threshold.defaultActionMessage', - { - defaultMessage: `\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} is in a state of \\{\\{context.alertState\\}\\} - -Reason: -\\{\\{context.reason\\}\\} -`, - } - ), + defaultActionMessage: inventoryDefaultActionMessage, + defaultRecoveryMessage: inventoryDefaultRecoveryMessage, requiresAppContext: false, format: formatReason, }; diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/log_threshold_rule_type.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/log_threshold_rule_type.tsx index 1d02f8291b0cf..d223e8ac8fa4f 100644 --- a/x-pack/plugins/infra/public/alerting/log_threshold/log_threshold_rule_type.tsx +++ b/x-pack/plugins/infra/public/alerting/log_threshold/log_threshold_rule_type.tsx @@ -18,6 +18,30 @@ import { InfraClientCoreSetup } from '../../types'; import { createRuleFormatter } from './rule_data_formatters'; import { validateExpression } from './validation'; +const logThresholdDefaultActionMessage = i18n.translate( + 'xpack.infra.logs.alerting.threshold.defaultActionMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active. + +\\{\\{^context.isRatio\\}\\}\\{\\{#context.group\\}\\}\\{\\{context.group\\}\\} - \\{\\{/context.group\\}\\}\\{\\{context.matchingDocuments\\}\\} log entries have matched the following conditions: \\{\\{context.conditions\\}\\}\\{\\{/context.isRatio\\}\\} +\\{\\{#context.isRatio\\}\\}\\{\\{#context.group\\}\\}\\{\\{context.group\\}\\} - \\{\\{/context.group\\}\\} Ratio of the count of log entries matching \\{\\{context.numeratorConditions\\}\\} to the count of log entries matching \\{\\{context.denominatorConditions\\}\\} was \\{\\{context.ratio\\}\\}\\{\\{/context.isRatio\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +const logThresholdDefaultRecoveryMessage = i18n.translate( + 'xpack.infra.logs.alerting.threshold.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{rule.name\\}\\} has recovered. + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); + export function createLogThresholdRuleType( core: InfraClientCoreSetup, logsLocator: LocatorPublic @@ -44,12 +68,8 @@ export function createLogThresholdRuleType( alertDetailsAppSection, ruleParamsExpression, validate: validateExpression, - defaultActionMessage: i18n.translate( - 'xpack.infra.logs.alerting.threshold.defaultActionMessage', - { - defaultMessage: `\\{\\{^context.isRatio\\}\\}\\{\\{#context.group\\}\\}\\{\\{context.group\\}\\} - \\{\\{/context.group\\}\\}\\{\\{context.matchingDocuments\\}\\} log entries have matched the following conditions: \\{\\{context.conditions\\}\\}\\{\\{/context.isRatio\\}\\}\\{\\{#context.isRatio\\}\\}\\{\\{#context.group\\}\\}\\{\\{context.group\\}\\} - \\{\\{/context.group\\}\\} Ratio of the count of log entries matching \\{\\{context.numeratorConditions\\}\\} to the count of log entries matching \\{\\{context.denominatorConditions\\}\\} was \\{\\{context.ratio\\}\\}\\{\\{/context.isRatio\\}\\}`, - } - ), + defaultActionMessage: logThresholdDefaultActionMessage, + defaultRecoveryMessage: logThresholdDefaultRecoveryMessage, requiresAppContext: false, format: createRuleFormatter(logsLocator), }; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/index.ts b/x-pack/plugins/infra/public/alerting/metric_threshold/index.ts index 5c519a02d6a7c..8512287bc7d19 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/index.ts +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/index.ts @@ -20,6 +20,36 @@ export interface MetricThresholdRuleTypeParams extends RuleTypeParams { criteria: MetricExpressionParams[]; } +const metricThresholdDefaultActionMessage = i18n.translate( + 'xpack.infra.metrics.alerting.metric.threshold.defaultActionMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: + +- Affected: \\{\\{context.group\\}\\} +- Metric: \\{\\{context.metric\\}\\} +- Observed value: \\{\\{context.value\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +const metricThresholdDefaultRecoveryMessage = i18n.translate( + 'xpack.infra.metrics.alerting.metric.threshold.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{rule.name\\}\\} has recovered. + +- Affected: \\{\\{context.group\\}\\} +- Metric: \\{\\{context.metric\\}\\} +- Threshold: \\{\\{context.threshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); + export function createMetricThresholdRuleType(): ObservabilityRuleTypeModel { return { id: METRIC_THRESHOLD_ALERT_TYPE_ID, @@ -32,16 +62,8 @@ export function createMetricThresholdRuleType(): ObservabilityRuleTypeModel import('./components/expression')), validate: validateMetricThreshold, - defaultActionMessage: i18n.translate( - 'xpack.infra.metrics.alerting.threshold.defaultActionMessage', - { - defaultMessage: `\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} is in a state of \\{\\{context.alertState\\}\\} - -Reason: -\\{\\{context.reason\\}\\} -`, - } - ), + defaultActionMessage: metricThresholdDefaultActionMessage, + defaultRecoveryMessage: metricThresholdDefaultRecoveryMessage, requiresAppContext: false, format: formatReason, alertDetailsAppSection: lazy(() => import('./components/alert_details_app_section')), diff --git a/x-pack/plugins/infra/server/lib/alerting/common/messages.ts b/x-pack/plugins/infra/server/lib/alerting/common/messages.ts index 6bc48083d252b..2caf83d309861 100644 --- a/x-pack/plugins/infra/server/lib/alerting/common/messages.ts +++ b/x-pack/plugins/infra/server/lib/alerting/common/messages.ts @@ -180,7 +180,7 @@ export const alertDetailUrlActionVariableDescription = i18n.translate( 'xpack.infra.metrics.alerting.alertDetailUrlActionVariableDescription', { defaultMessage: - 'Link to the view within Elastic that shows further details and context surrounding this alert', + 'Link to the alert troubleshooting view for further context and details. This will be an empty string if the server.publicBaseUrl is not configured.', } ); @@ -225,8 +225,7 @@ export const thresholdActionVariableDescription = i18n.translate( export const viewInAppUrlActionVariableDescription = i18n.translate( 'xpack.infra.metrics.alerting.viewInAppUrlActionVariableDescription', { - defaultMessage: - 'Link to the view or feature within Elastic that can assist with further investigation', + defaultMessage: 'Link to the alert source', } ); diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts index 00e4d1dbb8882..ccbf33bb6e84f 100644 --- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts @@ -94,8 +94,7 @@ const alertReasonMessageActionVariableDescription = i18n.translate( const viewInAppUrlActionVariableDescription = i18n.translate( 'xpack.infra.logs.alerting.threshold.viewInAppUrlActionVariableDescription', { - defaultMessage: - 'Link to the view or feature within Elastic that can be used to investigate the alert and its context further', + defaultMessage: 'Link to the alert source', } ); diff --git a/x-pack/plugins/infra/server/lib/infra_types.ts b/x-pack/plugins/infra/server/lib/infra_types.ts index 8733efd95402c..f9fe976f692a5 100644 --- a/x-pack/plugins/infra/server/lib/infra_types.ts +++ b/x-pack/plugins/infra/server/lib/infra_types.ts @@ -9,7 +9,6 @@ import type { Logger } from '@kbn/logging'; import type { IBasePath } from '@kbn/core/server'; import type { handleEsError } from '@kbn/es-ui-shared-plugin/server'; import type { AlertsLocatorParams } from '@kbn/observability-plugin/common'; -import { ObservabilityConfig } from '@kbn/observability-plugin/server'; import type { LocatorPublic } from '@kbn/share-plugin/common'; import { RulesServiceSetup } from '../services/rules'; import { InfraConfig, InfraPluginStartServicesAccessor } from '../types'; @@ -34,7 +33,6 @@ export interface InfraBackendLibs extends InfraDomainLibs { metricsRules: RulesServiceSetup; sources: InfraSources; sourceStatus: InfraSourceStatus; - getAlertDetailsConfig: () => ObservabilityConfig['unsafe']['alertDetails']; getStartServices: InfraPluginStartServicesAccessor; handleEsError: typeof handleEsError; logger: Logger; diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts index 4b7da8f9b4b77..04fea926a2083 100644 --- a/x-pack/plugins/infra/server/plugin.ts +++ b/x-pack/plugins/infra/server/plugin.ts @@ -208,7 +208,6 @@ export class InfraServerPlugin logsRules: this.logsRules.setup(core, plugins), metricsRules: this.metricsRules.setup(core, plugins), getStartServices: () => core.getStartServices(), - getAlertDetailsConfig: () => plugins.observability.getAlertDetailsConfig(), logger: this.logger, basePath: core.http.basePath, alertsLocator: plugins.share.url.locators.get(alertsLocatorID), diff --git a/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts b/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts index 73d394840d0d0..6d35ac3d01586 100644 --- a/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts +++ b/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts @@ -19,6 +19,39 @@ import { validateBurnRateRule } from '../components/burn_rate_rule_editor/valida import { validateMetricThreshold } from '../pages/threshold/components/validation'; import { formatReason } from '../pages/threshold/rule_data_formatters'; +const sloBurnRateDefaultActionMessage = i18n.translate( + 'xpack.observability.slo.rules.burnRate.defaultActionMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} is active with the following conditions: + +- SLO: \\{\\{context.sloName\\}\\}' +- The burn rate over the last \\{\\{context.longWindow.duration\\}\\} is \\{\\{context.longWindow.burnRate\\}\\} +- The burn rate over the last \\{\\{context.shortWindow.duration\\}\\} is \\{\\{context.shortWindow.burnRate\\}\\} +- Threshold: \\{\\{context.burnRateThreshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); +const sloBurnRateDefaultRecoveryMessage = i18n.translate( + 'xpack.observability.slo.rules.burnRate.defaultRecoveryMessage', + { + defaultMessage: `\\{\\{context.reason\\}\\} + +\\{\\{rule.name\\}\\} has recovered. + +- SLO: \\{\\{context.sloName\\}\\}' +- The burn rate over the last \\{\\{context.longWindow.duration\\}\\} is \\{\\{context.longWindow.burnRate\\}\\} +- The burn rate over the last \\{\\{context.shortWindow.duration\\}\\} is \\{\\{context.shortWindow.burnRate\\}\\} +- Threshold: \\{\\{context.burnRateThreshold\\}\\} + +[View alert details](\\{\\{context.alertDetailsUrl\\}\\}) +`, + } +); + export const registerObservabilityRuleTypes = ( config: ConfigSchema, observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry @@ -41,17 +74,8 @@ export const registerObservabilityRuleTypes = ( ruleParamsExpression: lazy(() => import('../components/burn_rate_rule_editor')), validate: validateBurnRateRule, requiresAppContext: false, - defaultActionMessage: i18n.translate( - 'xpack.observability.slo.rules.burnRate.defaultActionMessage', - { - defaultMessage: `The rule \\{\\{rule.name\\}\\} for the SLO '\\{\\{context.sloName\\}\\}' is firing: -- Reason: \\{\\{context.reason\\}\\} -- The burn rate over the last \\{\\{context.longWindow.duration\\}\\} is \\{\\{context.longWindow.burnRate\\}\\} -- The burn rate over the last \\{\\{context.shortWindow.duration\\}\\} is \\{\\{context.shortWindow.burnRate\\}\\} -- The burn rate threshold is set to \\{\\{context.burnRateThreshold\\}\\} -- View in the SLO details page: \\{\\{context.viewInAppUrl\\}\\}`, - } - ), + defaultActionMessage: sloBurnRateDefaultActionMessage, + defaultRecoveryMessage: sloBurnRateDefaultRecoveryMessage, }); if (config.unsafe.thresholdRule.enabled) { observabilityRuleTypeRegistry.register({ @@ -72,7 +96,7 @@ export const registerObservabilityRuleTypes = ( 'xpack.observability.threshold.rule.alerting.threshold.defaultActionMessage', { defaultMessage: `\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} is in a state of \\{\\{context.alertState\\}\\} - + Reason: \\{\\{context.reason\\}\\} `, diff --git a/x-pack/plugins/observability/server/lib/rules/threshold/messages.ts b/x-pack/plugins/observability/server/lib/rules/threshold/messages.ts index 2fc43883c0ed3..b302148664800 100644 --- a/x-pack/plugins/observability/server/lib/rules/threshold/messages.ts +++ b/x-pack/plugins/observability/server/lib/rules/threshold/messages.ts @@ -184,7 +184,7 @@ export const alertDetailUrlActionVariableDescription = i18n.translate( 'xpack.observability.threshold.rule.alertDetailUrlActionVariableDescription', { defaultMessage: - 'Link to the view within Elastic that shows further details and context surrounding this alert', + 'Link to the alert troubleshooting view for further context and details. This will be an empty string if the server.publicBaseUrl is not configured.', } ); @@ -229,8 +229,7 @@ export const thresholdActionVariableDescription = i18n.translate( export const viewInAppUrlActionVariableDescription = i18n.translate( 'xpack.observability.threshold.rule.viewInAppUrlActionVariableDescription', { - defaultMessage: - 'Link to the view or feature within Elastic that can assist with further investigation', + defaultMessage: 'Link to the alert source', } ); diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/alerts/action_variables.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/alerts/action_variables.ts index b3cd8d5817ff8..a06b2d3995f0f 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/alerts/action_variables.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/alerts/action_variables.ts @@ -37,7 +37,7 @@ export const ACTION_VARIABLES = { 'xpack.synthetics.alerts.monitorStatus.actionVariables.context.alertDetailUrl.description', { defaultMessage: - 'Link to the view within Elastic that shows further details and context surrounding this alert', + 'Link to the alert troubleshooting view for further context and details. This will be an empty string if the server.publicBaseUrl is not configured.', } ), usesPublicBaseUrl: true, @@ -47,8 +47,7 @@ export const ACTION_VARIABLES = { description: i18n.translate( 'xpack.synthetics.alerts.monitorStatus.actionVariables.context.viewInAppUrl.description', { - defaultMessage: - 'Link to the view or feature within Elastic that can be used to investigate the alert and its context further', + defaultMessage: 'Link to the alert source', } ), usesPublicBaseUrl: true, diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index a1a5ee63bd39e..acfab0c82bea1 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -19020,7 +19020,6 @@ "xpack.infra.metrics.alerting.threshold.belowRecovery": "inférieur à", "xpack.infra.metrics.alerting.threshold.betweenRecovery": "entre", "xpack.infra.metrics.alerting.threshold.customEquation": "Équation personnalisée", - "xpack.infra.metrics.alerting.threshold.defaultActionMessage": "\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} est à l'état \\{\\{context.alertState\\}\\}\n\nRaison :\n\\{\\{context.reason\\}\\}\n", "xpack.infra.metrics.alerting.threshold.documentCount": "Nombre de documents", "xpack.infra.metrics.alerting.threshold.errorState": "ERREUR", "xpack.infra.metrics.alerting.threshold.fired": "Alerte", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 9e49ac2bea3f2..87d4bd9bc7916 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -19019,7 +19019,6 @@ "xpack.infra.metrics.alerting.threshold.belowRecovery": "より小", "xpack.infra.metrics.alerting.threshold.betweenRecovery": "の間", "xpack.infra.metrics.alerting.threshold.customEquation": "カスタム等式", - "xpack.infra.metrics.alerting.threshold.defaultActionMessage": "\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\}は状態\\{\\{context.alertState\\}\\}です\n\n理由:\n\\{\\{context.reason\\}\\}\n", "xpack.infra.metrics.alerting.threshold.documentCount": "ドキュメントカウント", "xpack.infra.metrics.alerting.threshold.errorState": "エラー", "xpack.infra.metrics.alerting.threshold.fired": "アラート", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 1b373abbe3ee3..473cab9ace496 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -19019,7 +19019,6 @@ "xpack.infra.metrics.alerting.threshold.belowRecovery": "低于", "xpack.infra.metrics.alerting.threshold.betweenRecovery": "介于", "xpack.infra.metrics.alerting.threshold.customEquation": "定制方程", - "xpack.infra.metrics.alerting.threshold.defaultActionMessage": "\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} 处于 \\{\\{context.alertState\\}\\} 状态\n\n原因:\n\\{\\{context.reason\\}\\}\n", "xpack.infra.metrics.alerting.threshold.documentCount": "文档计数", "xpack.infra.metrics.alerting.threshold.errorState": "错误", "xpack.infra.metrics.alerting.threshold.fired": "告警", diff --git a/x-pack/test/apm_api_integration/tests/alerts/error_count_threshold.spec.ts b/x-pack/test/apm_api_integration/tests/alerts/error_count_threshold.spec.ts index bae143342bffd..84aa1046c4d88 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/error_count_threshold.spec.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/error_count_threshold.spec.ts @@ -120,8 +120,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { { message: `${errorCountMessage} - Transaction name: {{context.transactionName}} -- Error grouping key: {{context.errorGroupingKey}} -- Alert URL: {{context.alertDetailsUrl}}`, +- Error grouping key: {{context.errorGroupingKey}}`, }, ], }, @@ -169,15 +168,19 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); expect(resp.hits.hits[0]._source?.message).eql( - `Apm error count alert is firing because of the following conditions: + `Error count is 15 in the last 1 hr for service: opbeans-java, env: production, name: tx-java, error key: ${errorGroupingKey}. Alert when > 1. + +Apm error count is active with the following conditions: - Service name: opbeans-java - Environment: production +- Error count: 15 errors over the last 1 hr - Threshold: 1 -- Triggered value: 15 errors over the last 1 hr + +[View alert details](http://mockedpublicbaseurl/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)) + - Transaction name: tx-java -- Error grouping key: ${errorGroupingKey} -- Alert URL: http://mockedpublicbaseurl/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` +- Error grouping key: ${errorGroupingKey}` ); });