diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts index 937386e2c4928..81da325350dbd 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts @@ -4,11 +4,17 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ + import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { KibanaRequest } from '@kbn/core/server'; import datemath from '@kbn/datemath'; import type { ESSearchResponse } from '@kbn/es-types'; -import { getAlertUrl, ProcessorEvent } from '@kbn/observability-plugin/common'; +import { + getAlertUrl, + observabilityPaths, + ProcessorEvent, +} from '@kbn/observability-plugin/common'; import { termQuery } from '@kbn/observability-plugin/server'; import { ALERT_EVALUATION_THRESHOLD, @@ -329,6 +335,8 @@ export function registerAnomalyRuleType({ return { state: {} }; }, alerts: ApmRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }) ); } diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts index 78f3d6c97e654..fe405aafd3c22 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts @@ -5,9 +5,11 @@ * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { formatDurationFromTimeUnitChar, getAlertUrl, + observabilityPaths, ProcessorEvent, TimeUnitChar, } from '@kbn/observability-plugin/common'; @@ -254,6 +256,8 @@ export function registerErrorCountRuleType({ return { state: {} }; }, alerts: ApmRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }) ); } diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts index 4f07f7f1fbf72..66e3c8a725632 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts @@ -6,10 +6,12 @@ */ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { asDuration, formatDurationFromTimeUnitChar, getAlertDetailsUrl, + observabilityPaths, ProcessorEvent, TimeUnitChar, } from '@kbn/observability-plugin/common'; @@ -298,6 +300,8 @@ export function registerTransactionDurationRuleType({ return { state: {} }; }, alerts: ApmRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); alerting.registerType(ruleType); diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts index 4aef808b33f3a..845aa18b21107 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts @@ -5,9 +5,11 @@ * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { formatDurationFromTimeUnitChar, getAlertUrl, + observabilityPaths, ProcessorEvent, TimeUnitChar, } from '@kbn/observability-plugin/common'; @@ -306,6 +308,8 @@ export function registerTransactionErrorRateRuleType({ return { state: {} }; }, alerts: ApmRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }) ); } diff --git a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts index 96b076cb812b9..3e129018013f8 100644 --- a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/register_inventory_metric_threshold_rule_type.ts @@ -7,7 +7,8 @@ import { schema, Type } from '@kbn/config-schema'; import { i18n } from '@kbn/i18n'; -import { PluginSetupContract } from '@kbn/alerting-plugin/server'; +import { GetViewInAppRelativeUrlFnOpts, PluginSetupContract } from '@kbn/alerting-plugin/server'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; import { TimeUnitChar } from '@kbn/observability-plugin/common/utils/formatters/duration'; import { Comparator, @@ -147,5 +148,7 @@ export async function registerMetricInventoryThresholdRuleType( }, alerts: MetricsRulesTypeAlertDefinition, fieldsForAAD: O11Y_AAD_FIELDS, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); } 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 83b3ba673e3da..58fdb97281b56 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 @@ -6,7 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { PluginSetupContract } from '@kbn/alerting-plugin/server'; +import { GetViewInAppRelativeUrlFnOpts, PluginSetupContract } from '@kbn/alerting-plugin/server'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; import { O11Y_AAD_FIELDS } from '../../../../common/constants'; import { createLogThresholdExecutor, FIRED_ACTIONS } from './log_threshold_executor'; import { extractReferences, injectReferences } from './log_threshold_references_manager'; @@ -166,5 +167,7 @@ export async function registerLogThresholdRuleType( }, alerts: LogsRulesTypeAlertDefinition, fieldsForAAD: O11Y_AAD_FIELDS, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); } diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts index 37b1ce55a98dc..9e5c4c70e96d4 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts @@ -12,8 +12,10 @@ import { RuleType, AlertInstanceState as AlertState, AlertInstanceContext as AlertContext, + GetViewInAppRelativeUrlFnOpts, } from '@kbn/alerting-plugin/server'; import { RecoveredActionGroupId } from '@kbn/alerting-plugin/common'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; import { O11Y_AAD_FIELDS } from '../../../../common/constants'; import { createMetricAnomalyExecutor, @@ -116,4 +118,6 @@ export const registerMetricAnomalyRuleType = ( }, ], }, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts index 8635d4196ce29..1e8904a3a729d 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts @@ -8,7 +8,12 @@ import { schema } from '@kbn/config-schema'; import { i18n } from '@kbn/i18n'; import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; -import { PluginSetupContract, RuleType } from '@kbn/alerting-plugin/server'; +import { + GetViewInAppRelativeUrlFnOpts, + PluginSetupContract, + RuleType, +} from '@kbn/alerting-plugin/server'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; import { Comparator, METRIC_THRESHOLD_ALERT_TYPE_ID } from '../../../../common/alerting/metrics'; import { METRIC_EXPLORER_AGGREGATIONS } from '../../../../common/http_api'; import { InfraBackendLibs } from '../../infra_types'; @@ -185,5 +190,7 @@ export async function registerMetricThresholdRuleType( }, producer: 'infrastructure', alerts: MetricsRulesTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); } diff --git a/x-pack/plugins/observability/common/index.ts b/x-pack/plugins/observability/common/index.ts index b0c87966ef89b..10af8c30b3bbe 100644 --- a/x-pack/plugins/observability/common/index.ts +++ b/x-pack/plugins/observability/common/index.ts @@ -67,4 +67,6 @@ export const rulesLocatorID = 'RULES_LOCATOR'; export const sloDetailsLocatorID = 'SLO_DETAILS_LOCATOR'; export const sloEditLocatorID = 'SLO_EDIT_LOCATOR'; +import { paths } from './locators/paths'; +export const observabilityPaths = paths.observability; export type { AlertsLocatorParams } from './locators/alerts'; diff --git a/x-pack/plugins/observability/server/lib/rules/slo_burn_rate/register.ts b/x-pack/plugins/observability/server/lib/rules/slo_burn_rate/register.ts index 8bff7173764df..f9c8024dc55d3 100644 --- a/x-pack/plugins/observability/server/lib/rules/slo_burn_rate/register.ts +++ b/x-pack/plugins/observability/server/lib/rules/slo_burn_rate/register.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { schema } from '@kbn/config-schema'; import { i18n } from '@kbn/i18n'; import { LicenseType } from '@kbn/licensing-plugin/server'; @@ -12,7 +13,7 @@ import { createLifecycleExecutor } from '@kbn/rule-registry-plugin/server'; import { legacyExperimentalFieldMap } from '@kbn/alerts-as-data-utils'; import { IBasePath } from '@kbn/core/server'; import { LocatorPublic } from '@kbn/share-plugin/common'; -import { AlertsLocatorParams, sloFeatureId } from '../../../../common'; +import { AlertsLocatorParams, observabilityPaths, sloFeatureId } from '../../../../common'; import { SLO_RULE_REGISTRATION_CONTEXT } from '../../../common/constants'; import { @@ -85,6 +86,8 @@ export function sloBurnRateRuleType( useEcs: false, useLegacyAlerts: true, }, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }; } diff --git a/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts b/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts index 0c3b53c269371..823d9eb6efc6f 100644 --- a/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts +++ b/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts @@ -15,8 +15,11 @@ import { createLifecycleExecutor, IRuleDataClient } from '@kbn/rule-registry-plu import { LicenseType } from '@kbn/licensing-plugin/server'; import { LocatorPublic } from '@kbn/share-plugin/common'; import { EsQueryRuleParamsExtractedParams } from '@kbn/stack-alerts-plugin/server/rule_types/es_query/rule_type_params'; -import { paths } from '../../../../common/locators/paths'; -import { AlertsLocatorParams, observabilityFeatureId } from '../../../../common'; +import { + AlertsLocatorParams, + observabilityFeatureId, + observabilityPaths, +} from '../../../../common'; import { Comparator } from '../../../../common/threshold_rule/types'; import { OBSERVABILITY_THRESHOLD_RULE_TYPE_ID } from '../../../../common/constants'; import { THRESHOLD_RULE_REGISTRATION_CONTEXT } from '../../../common/constants'; @@ -181,8 +184,7 @@ export function thresholdRuleType( }, producer: observabilityFeatureId, alerts: MetricsRulesTypeAlertDefinition, - getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => { - return paths.observability.ruleDetails(rule.id); - }, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }; } diff --git a/x-pack/plugins/synthetics/server/alert_rules/status_rule/monitor_status_rule.ts b/x-pack/plugins/synthetics/server/alert_rules/status_rule/monitor_status_rule.ts index 4704afa1ce8cf..61173f7b0c227 100644 --- a/x-pack/plugins/synthetics/server/alert_rules/status_rule/monitor_status_rule.ts +++ b/x-pack/plugins/synthetics/server/alert_rules/status_rule/monitor_status_rule.ts @@ -4,8 +4,11 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ + import { isEmpty } from 'lodash'; import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; import { createLifecycleRuleTypeFactory, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; import { SyntheticsPluginsSetupDependencies, SyntheticsServerSetup } from '../../types'; import { DOWN_LABEL, getMonitorAlertDocument, getMonitorSummary } from './message_utils'; @@ -155,5 +158,7 @@ export const registerSyntheticsStatusCheckRule = ( }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); }; diff --git a/x-pack/plugins/synthetics/server/alert_rules/tls_rule/tls_rule.ts b/x-pack/plugins/synthetics/server/alert_rules/tls_rule/tls_rule.ts index 29ab0982366c2..67fa4b352cd1f 100644 --- a/x-pack/plugins/synthetics/server/alert_rules/tls_rule/tls_rule.ts +++ b/x-pack/plugins/synthetics/server/alert_rules/tls_rule/tls_rule.ts @@ -4,7 +4,9 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ + import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { createLifecycleRuleTypeFactory, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; import { asyncForEach } from '@kbn/std'; import { ALERT_REASON, ALERT_UUID } from '@kbn/rule-data-utils'; @@ -12,6 +14,7 @@ import { alertsLocatorID, AlertsLocatorParams, getAlertUrl, + observabilityPaths, } from '@kbn/observability-plugin/common'; import { LocatorPublic } from '@kbn/share-plugin/common'; import { schema } from '@kbn/config-schema'; @@ -148,5 +151,7 @@ export const registerSyntheticsTLSCheckRule = ( return { state: updateState(ruleState, foundCerts) }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); }; diff --git a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/duration_anomaly.ts b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/duration_anomaly.ts index a378f2d2a7fc5..870272fcbe402 100644 --- a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/duration_anomaly.ts +++ b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/duration_anomaly.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import moment from 'moment'; import { KibanaRequest, SavedObjectsClientContract } from '@kbn/core/server'; import { schema } from '@kbn/config-schema'; @@ -19,6 +20,7 @@ import { alertsLocatorID, AlertsLocatorParams, getAlertUrl, + observabilityPaths, } from '@kbn/observability-plugin/common'; import { LocatorPublic } from '@kbn/share-plugin/common'; import { asyncForEach } from '@kbn/std'; @@ -226,4 +228,6 @@ export const durationAnomalyAlertFactory: UptimeAlertTypeFactory return { state: updateState(state, foundAnomalies) }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); diff --git a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/status_check.ts b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/status_check.ts index 55b8ff60c27d6..18de47f44ac87 100644 --- a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/status_check.ts +++ b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/status_check.ts @@ -4,6 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { min } from 'lodash'; import moment from 'moment'; @@ -19,6 +20,7 @@ import { AlertsLocatorParams, formatDurationFromTimeUnitChar, getAlertUrl, + observabilityPaths, TimeUnitChar, } from '@kbn/observability-plugin/common'; import { LocatorPublic } from '@kbn/share-plugin/common'; @@ -572,4 +574,6 @@ export const statusCheckAlertFactory: UptimeAlertTypeFactory = ( return { state: updateState(state, downMonitorsByLocation.length > 0) }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); diff --git a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls.ts b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls.ts index eb40a709174e7..f84ec4ed8589f 100644 --- a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls.ts +++ b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import moment from 'moment'; import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; import { schema } from '@kbn/config-schema'; @@ -12,6 +13,7 @@ import { alertsLocatorID, AlertsLocatorParams, getAlertUrl, + observabilityPaths, } from '@kbn/observability-plugin/common'; import { LocatorPublic } from '@kbn/share-plugin/common'; import { ALERT_REASON, ALERT_UUID } from '@kbn/rule-data-utils'; @@ -257,4 +259,6 @@ export const tlsAlertFactory: UptimeAlertTypeFactory = ( return { state: updateState(state, foundCerts) }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); diff --git a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls_legacy.ts b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls_legacy.ts index 871157229b0a3..4393e4fde3e71 100644 --- a/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls_legacy.ts +++ b/x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls_legacy.ts @@ -5,11 +5,12 @@ * 2.0. */ +import { observabilityPaths } from '@kbn/observability-plugin/common'; import moment from 'moment'; import { schema } from '@kbn/config-schema'; import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; import { AlertInstanceContext } from '@kbn/alerting-plugin/common'; -import { Alert } from '@kbn/alerting-plugin/server'; +import { Alert, GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { UptimeAlertTypeFactory } from './types'; import { updateState } from './common'; import { CLIENT_ALERT_TYPES, TLS_LEGACY } from '../../../../common/constants/uptime_alerts'; @@ -166,4 +167,6 @@ export const tlsLegacyAlertFactory: UptimeAlertTypeFactory = (_s return { state: updateState(state, foundCerts) }; }, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), });