From 02b611543692bccb3a4a81aff9e1fb742bbd8c88 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 13:52:58 +0200 Subject: [PATCH] Configure observability rule URL for uptime rule types --- .../server/legacy_uptime/lib/alerts/duration_anomaly.ts | 4 ++++ .../uptime/server/legacy_uptime/lib/alerts/status_check.ts | 4 ++++ x-pack/plugins/uptime/server/legacy_uptime/lib/alerts/tls.ts | 4 ++++ .../uptime/server/legacy_uptime/lib/alerts/tls_legacy.ts | 5 ++++- 4 files changed, 16 insertions(+), 1 deletion(-) 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 dd713718a2c12..1a3a001d9f7e8 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'; @@ -573,4 +575,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), });