From 9e56ed878497103958249005835d3ee84c6bae58 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 3 Aug 2023 17:13:59 +0200 Subject: [PATCH 1/8] Update rule details link for the threshold rule --- x-pack/plugins/alerting/server/index.ts | 1 + .../{public/routes => common/locators}/paths.ts | 0 .../public/components/alerts_flyout/alerts_flyout_body.tsx | 2 +- .../components/alerts_flyout/alerts_flyout_footer.tsx | 2 +- .../slo/slo_status_badge/slo_active_alerts_badge.tsx | 2 +- .../observability/public/hooks/slo/use_create_slo.ts | 2 +- .../observability/public/locators/rule_details.test.ts | 2 +- .../plugins/observability/public/locators/rule_details.ts | 2 +- x-pack/plugins/observability/public/locators/rules.test.ts | 2 +- x-pack/plugins/observability/public/locators/rules.ts | 2 +- x-pack/plugins/observability/public/locators/slo_details.ts | 2 +- x-pack/plugins/observability/public/locators/slo_edit.ts | 2 +- .../public/pages/alert_details/alert_details.tsx | 2 +- .../public/pages/alerts/components/alert_actions.tsx | 2 +- .../observability/public/pages/cases/components/cases.tsx | 2 +- .../overview/components/observability_status/content.ts | 2 +- .../overview/components/sections/empty/empty_sections.tsx | 2 +- .../observability/public/pages/overview/overview.tsx | 2 +- .../public/pages/rule_details/rule_details.tsx | 2 +- .../public/pages/slo_details/components/header_control.tsx | 2 +- .../public/pages/slo_details/slo_details.test.tsx | 2 +- .../observability/public/pages/slo_details/slo_details.tsx | 2 +- .../public/pages/slo_edit/components/slo_edit_form.tsx | 2 +- .../observability/public/pages/slo_edit/slo_edit.test.tsx | 2 +- .../observability/public/pages/slo_edit/slo_edit.tsx | 2 +- .../public/pages/slos/components/slo_list_item.tsx | 2 +- .../plugins/observability/public/pages/slos/slos.test.tsx | 2 +- x-pack/plugins/observability/public/pages/slos/slos.tsx | 2 +- .../public/pages/slos_welcome/slos_welcome.test.tsx | 2 +- .../public/pages/slos_welcome/slos_welcome.tsx | 2 +- x-pack/plugins/observability/public/plugin.ts | 2 +- x-pack/plugins/observability/public/routes/routes.tsx | 2 +- .../lib/rules/threshold/register_threshold_rule_type.ts | 6 +++++- 33 files changed, 36 insertions(+), 31 deletions(-) rename x-pack/plugins/observability/{public/routes => common/locators}/paths.ts (100%) diff --git a/x-pack/plugins/alerting/server/index.ts b/x-pack/plugins/alerting/server/index.ts index 131cfb54a3a9c..ebfe1586031fa 100644 --- a/x-pack/plugins/alerting/server/index.ts +++ b/x-pack/plugins/alerting/server/index.ts @@ -31,6 +31,7 @@ export type { SummarizedAlertsChunk, ExecutorType, IRuleTypeAlerts, + GetViewInAppRelativeUrlFnOpts, } from './types'; export { RuleNotifyWhen } from '../common'; export { DEFAULT_MAX_EPHEMERAL_ACTIONS_PER_ALERT } from './config'; diff --git a/x-pack/plugins/observability/public/routes/paths.ts b/x-pack/plugins/observability/common/locators/paths.ts similarity index 100% rename from x-pack/plugins/observability/public/routes/paths.ts rename to x-pack/plugins/observability/common/locators/paths.ts diff --git a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx index 06cdd72626ec4..297ee793289f4 100644 --- a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx +++ b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx @@ -32,7 +32,7 @@ import moment from 'moment-timezone'; import { useUiSetting } from '@kbn/kibana-react-plugin/public'; import { useKibana } from '../../utils/kibana_react'; import { asDuration } from '../../../common/utils/formatters'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { formatAlertEvaluationValue } from '../../utils/format_alert_evaluation_value'; import { RULE_DETAILS_PAGE_ID } from '../../pages/rule_details/constants'; import type { TopAlert } from '../../typings/alerts'; diff --git a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_footer.tsx b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_footer.tsx index 3f64b1000d0df..27cbd3a62fdc6 100644 --- a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_footer.tsx +++ b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_footer.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { useKibana } from '../../utils/kibana_react'; import { usePluginContext } from '../../hooks/use_plugin_context'; import { isAlertDetailsEnabledPerApp } from '../../utils/is_alert_details_enabled'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import type { TopAlert } from '../../typings/alerts'; interface FlyoutProps { diff --git a/x-pack/plugins/observability/public/components/slo/slo_status_badge/slo_active_alerts_badge.tsx b/x-pack/plugins/observability/public/components/slo/slo_status_badge/slo_active_alerts_badge.tsx index df75dcbdf3c35..a150c5aa2d88a 100644 --- a/x-pack/plugins/observability/public/components/slo/slo_status_badge/slo_active_alerts_badge.tsx +++ b/x-pack/plugins/observability/public/components/slo/slo_status_badge/slo_active_alerts_badge.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { SLOWithSummaryResponse } from '@kbn/slo-schema'; -import { paths } from '../../../routes/paths'; +import { paths } from '../../../../common/locators/paths'; import { useKibana } from '../../../utils/kibana_react'; import { ActiveAlerts } from '../../../hooks/slo/use_fetch_active_alerts'; diff --git a/x-pack/plugins/observability/public/hooks/slo/use_create_slo.ts b/x-pack/plugins/observability/public/hooks/slo/use_create_slo.ts index 8debbc4b9eefd..ca2a0435b741f 100644 --- a/x-pack/plugins/observability/public/hooks/slo/use_create_slo.ts +++ b/x-pack/plugins/observability/public/hooks/slo/use_create_slo.ts @@ -10,7 +10,7 @@ import { encode } from '@kbn/rison'; import type { CreateSLOInput, CreateSLOResponse, FindSLOResponse } from '@kbn/slo-schema'; import { QueryKey, useMutation, useQueryClient } from '@tanstack/react-query'; import { v1 as uuidv1 } from 'uuid'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { useKibana } from '../../utils/kibana_react'; import { sloKeys } from './query_key_factory'; diff --git a/x-pack/plugins/observability/public/locators/rule_details.test.ts b/x-pack/plugins/observability/public/locators/rule_details.test.ts index 27d9cef8f1d12..9352b3f9ea5aa 100644 --- a/x-pack/plugins/observability/public/locators/rule_details.test.ts +++ b/x-pack/plugins/observability/public/locators/rule_details.test.ts @@ -11,7 +11,7 @@ import { RULE_DETAILS_ALERTS_TAB, } from '../pages/rule_details/constants'; import { getRuleDetailsPath, RuleDetailsLocatorDefinition } from './rule_details'; -import { RULES_PATH } from '../routes/paths'; +import { RULES_PATH } from '../../common/locators/paths'; describe('RuleDetailsLocator', () => { const locator = new RuleDetailsLocatorDefinition(); diff --git a/x-pack/plugins/observability/public/locators/rule_details.ts b/x-pack/plugins/observability/public/locators/rule_details.ts index 867eb97a45b5a..8dde669f4b8b6 100644 --- a/x-pack/plugins/observability/public/locators/rule_details.ts +++ b/x-pack/plugins/observability/public/locators/rule_details.ts @@ -9,7 +9,7 @@ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import type { SerializableRecord } from '@kbn/utility-types'; import type { LocatorDefinition } from '@kbn/share-plugin/public'; import { ruleDetailsLocatorID } from '../../common'; -import { RULES_PATH } from '../routes/paths'; +import { RULES_PATH } from '../../common/locators/paths'; import { ALL_ALERTS } from '../components/alert_search_bar/constants'; import { RULE_DETAILS_ALERTS_TAB, diff --git a/x-pack/plugins/observability/public/locators/rules.test.ts b/x-pack/plugins/observability/public/locators/rules.test.ts index b73e58fa9d20d..c96a75de74c6e 100644 --- a/x-pack/plugins/observability/public/locators/rules.test.ts +++ b/x-pack/plugins/observability/public/locators/rules.test.ts @@ -6,7 +6,7 @@ */ import { RulesLocatorDefinition } from './rules'; -import { RULES_PATH } from '../routes/paths'; +import { RULES_PATH } from '../../common/locators/paths'; describe('RulesLocator', () => { const locator = new RulesLocatorDefinition(); diff --git a/x-pack/plugins/observability/public/locators/rules.ts b/x-pack/plugins/observability/public/locators/rules.ts index 379d34050d7f4..673b567c0f32f 100644 --- a/x-pack/plugins/observability/public/locators/rules.ts +++ b/x-pack/plugins/observability/public/locators/rules.ts @@ -10,7 +10,7 @@ import type { SerializableRecord } from '@kbn/utility-types'; import type { LocatorDefinition } from '@kbn/share-plugin/public'; import type { RuleStatus } from '@kbn/triggers-actions-ui-plugin/public'; import { rulesLocatorID } from '../../common'; -import { RULES_PATH } from '../routes/paths'; +import { RULES_PATH } from '../../common/locators/paths'; // eslint-disable-next-line @typescript-eslint/consistent-type-definitions export type RulesParams = { diff --git a/x-pack/plugins/observability/public/locators/slo_details.ts b/x-pack/plugins/observability/public/locators/slo_details.ts index fd981a0ae4493..e7b5cdd363f65 100644 --- a/x-pack/plugins/observability/public/locators/slo_details.ts +++ b/x-pack/plugins/observability/public/locators/slo_details.ts @@ -8,7 +8,7 @@ import type { SerializableRecord } from '@kbn/utility-types'; import type { LocatorDefinition } from '@kbn/share-plugin/public'; import { sloDetailsLocatorID } from '../../common'; -import { SLOS_PATH } from '../routes/paths'; +import { SLOS_PATH } from '../../common/locators/paths'; // eslint-disable-next-line @typescript-eslint/consistent-type-definitions export type SloDetailsParams = { diff --git a/x-pack/plugins/observability/public/locators/slo_edit.ts b/x-pack/plugins/observability/public/locators/slo_edit.ts index bac7354d34190..1f2ffc37bab89 100644 --- a/x-pack/plugins/observability/public/locators/slo_edit.ts +++ b/x-pack/plugins/observability/public/locators/slo_edit.ts @@ -11,7 +11,7 @@ import type { SerializableRecord } from '@kbn/utility-types'; import type { LocatorDefinition } from '@kbn/share-plugin/public'; import type { CreateSLOForm } from '../pages/slo_edit/types'; import { sloEditLocatorID } from '../../common'; -import { SLO_CREATE_PATH, SLOS_PATH } from '../routes/paths'; +import { SLO_CREATE_PATH, SLOS_PATH } from '../../common/locators/paths'; export type SloEditParams = RecursivePartial; diff --git a/x-pack/plugins/observability/public/pages/alert_details/alert_details.tsx b/x-pack/plugins/observability/public/pages/alert_details/alert_details.tsx index 0cdfd24b7ec73..7695a6d7d6758 100644 --- a/x-pack/plugins/observability/public/pages/alert_details/alert_details.tsx +++ b/x-pack/plugins/observability/public/pages/alert_details/alert_details.tsx @@ -26,7 +26,7 @@ import PageNotFound from '../404'; import { getTimeZone } from '../../utils/get_time_zone'; import { isAlertDetailsEnabledPerApp } from '../../utils/is_alert_details_enabled'; import { observabilityFeatureId } from '../../../common'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; interface AlertDetailsPathParams { alertId: string; diff --git a/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx index 11a8e21987ea7..b82b45f1065e2 100644 --- a/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx @@ -27,7 +27,7 @@ import { useKibana } from '../../../utils/kibana_react'; import { useGetUserCasesPermissions } from '../../../hooks/use_get_user_cases_permissions'; import { isAlertDetailsEnabledPerApp } from '../../../utils/is_alert_details_enabled'; import { parseAlert } from '../helpers/parse_alert'; -import { paths } from '../../../routes/paths'; +import { paths } from '../../../../common/locators/paths'; import { RULE_DETAILS_PAGE_ID } from '../../rule_details/constants'; import type { ObservabilityRuleTypeRegistry } from '../../..'; import type { ConfigSchema } from '../../../plugin'; diff --git a/x-pack/plugins/observability/public/pages/cases/components/cases.tsx b/x-pack/plugins/observability/public/pages/cases/components/cases.tsx index 33dbe68167b14..ce4c56e136eb5 100644 --- a/x-pack/plugins/observability/public/pages/cases/components/cases.tsx +++ b/x-pack/plugins/observability/public/pages/cases/components/cases.tsx @@ -13,7 +13,7 @@ import { usePluginContext } from '../../../hooks/use_plugin_context'; import { useFetchAlertDetail } from '../../../hooks/use_fetch_alert_detail'; import { useFetchAlertData } from '../../../hooks/use_fetch_alert_data'; import { LazyAlertsFlyout } from '../../..'; -import { CASES_PATH, paths } from '../../../routes/paths'; +import { CASES_PATH, paths } from '../../../../common/locators/paths'; export interface CasesProps { permissions: CasesPermissions; diff --git a/x-pack/plugins/observability/public/pages/overview/components/observability_status/content.ts b/x-pack/plugins/observability/public/pages/overview/components/observability_status/content.ts index a851df805f257..0c192d284147a 100644 --- a/x-pack/plugins/observability/public/pages/overview/components/observability_status/content.ts +++ b/x-pack/plugins/observability/public/pages/overview/components/observability_status/content.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { HttpSetup, DocLinksStart } from '@kbn/core/public'; import { ObservabilityFetchDataPlugins } from '../../../../typings/fetch_overview_data'; -import { paths } from '../../../../routes/paths'; +import { paths } from '../../../../../common/locators/paths'; export interface ObservabilityStatusContent { id: ObservabilityFetchDataPlugins | 'alert'; diff --git a/x-pack/plugins/observability/public/pages/overview/components/sections/empty/empty_sections.tsx b/x-pack/plugins/observability/public/pages/overview/components/sections/empty/empty_sections.tsx index 912b6c95f0d8d..9dc940008a96e 100644 --- a/x-pack/plugins/observability/public/pages/overview/components/sections/empty/empty_sections.tsx +++ b/x-pack/plugins/observability/public/pages/overview/components/sections/empty/empty_sections.tsx @@ -13,7 +13,7 @@ import { HttpSetup } from '@kbn/core/public'; import { FETCH_STATUS } from '@kbn/observability-shared-plugin/public'; import { useKibana } from '../../../../../utils/kibana_react'; -import { paths } from '../../../../../routes/paths'; +import { paths } from '../../../../../../common/locators/paths'; import { useHasData } from '../../../../../hooks/use_has_data'; import { EmptySection, Section } from './empty_section'; diff --git a/x-pack/plugins/observability/public/pages/overview/overview.tsx b/x-pack/plugins/observability/public/pages/overview/overview.tsx index 2f468310a13e3..eb39d19fb5bd7 100644 --- a/x-pack/plugins/observability/public/pages/overview/overview.tsx +++ b/x-pack/plugins/observability/public/pages/overview/overview.tsx @@ -23,7 +23,7 @@ import { Resources } from './components/resources'; import { NewsFeed } from './components/news_feed/news_feed'; import { ObservabilityStatusProgress } from './components/observability_status/observability_status_progress'; import { observabilityAlertFeatureIds } from '../../../common/constants'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { useDatePickerContext } from '../../hooks/use_date_picker_context'; import { useGuidedSetupProgress } from '../../hooks/use_guided_setup_progress'; import { useHasData } from '../../hooks/use_has_data'; diff --git a/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx b/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx index b0180607d495d..71ffbc9ed9335 100644 --- a/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx +++ b/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx @@ -32,7 +32,7 @@ import { RULE_DETAILS_ALERTS_TAB, RULE_DETAILS_TAB_URL_STORAGE_KEY, } from './constants'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { defaultTimeRange, getDefaultAlertSummaryTimeRange, diff --git a/x-pack/plugins/observability/public/pages/slo_details/components/header_control.tsx b/x-pack/plugins/observability/public/pages/slo_details/components/header_control.tsx index 22855556997a9..b62b4c675691f 100644 --- a/x-pack/plugins/observability/public/pages/slo_details/components/header_control.tsx +++ b/x-pack/plugins/observability/public/pages/slo_details/components/header_control.tsx @@ -18,7 +18,7 @@ import { isApmIndicatorType } from '../../../utils/slo/indicator'; import { convertSliApmParamsToApmAppDeeplinkUrl } from '../../../utils/slo/convert_sli_apm_params_to_apm_app_deeplink_url'; import { SLO_BURN_RATE_RULE_TYPE_ID } from '../../../../common/constants'; import { rulesLocatorID, sloFeatureId } from '../../../../common'; -import { paths } from '../../../routes/paths'; +import { paths } from '../../../../common/locators/paths'; import { transformSloResponseToCreateSloForm, transformCreateSLOFormToCreateSLOInput, diff --git a/x-pack/plugins/observability/public/pages/slo_details/slo_details.test.tsx b/x-pack/plugins/observability/public/pages/slo_details/slo_details.test.tsx index 2c1a1ebcae875..bcbb151251abf 100644 --- a/x-pack/plugins/observability/public/pages/slo_details/slo_details.test.tsx +++ b/x-pack/plugins/observability/public/pages/slo_details/slo_details.test.tsx @@ -20,7 +20,7 @@ import { useDeleteSlo } from '../../hooks/slo/use_delete_slo'; import { render } from '../../utils/test_helper'; import { SloDetailsPage } from './slo_details'; import { buildSlo } from '../../data/slo/slo'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { HEALTHY_STEP_DOWN_ROLLING_SLO, historicalSummaryData, diff --git a/x-pack/plugins/observability/public/pages/slo_details/slo_details.tsx b/x-pack/plugins/observability/public/pages/slo_details/slo_details.tsx index 1531e3305fc52..c4ea8ca7756dc 100644 --- a/x-pack/plugins/observability/public/pages/slo_details/slo_details.tsx +++ b/x-pack/plugins/observability/public/pages/slo_details/slo_details.tsx @@ -23,7 +23,7 @@ import PageNotFound from '../404'; import { SloDetails } from './components/slo_details'; import { HeaderTitle } from './components/header_title'; import { HeaderControl } from './components/header_control'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import type { SloDetailsPathParams } from './types'; import { AutoRefreshButton } from '../slos/components/auto_refresh_button'; import { FeedbackButton } from '../../components/slo/feedback_button/feedback_button'; diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx index 1ff446c005c01..ba3970d93cab0 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx @@ -20,7 +20,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { FormProvider, useForm } from 'react-hook-form'; import { sloFeatureId } from '../../../../common'; import { SLO_BURN_RATE_RULE_TYPE_ID } from '../../../../common/constants'; -import { paths } from '../../../routes/paths'; +import { paths } from '../../../../common/locators/paths'; import { useCreateSlo } from '../../../hooks/slo/use_create_slo'; import { useFetchRulesForSlo } from '../../../hooks/slo/use_fetch_rules_for_slo'; import { useUpdateSlo } from '../../../hooks/slo/use_update_slo'; diff --git a/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.test.tsx b/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.test.tsx index 7746e2b99545e..c35bcf0368357 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.test.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.test.tsx @@ -23,7 +23,7 @@ import { useUpdateSlo } from '../../hooks/slo/use_update_slo'; import { useFetchApmSuggestions } from '../../hooks/slo/use_fetch_apm_suggestions'; import { kibanaStartMock } from '../../utils/kibana_react.mock'; import { buildSlo } from '../../data/slo/slo'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { SloEditPage } from './slo_edit'; import { useCapabilities } from '../../hooks/slo/use_capabilities'; diff --git a/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.tsx b/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.tsx index 9b64d09e29343..fa4dc433e3f5f 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/slo_edit.tsx @@ -10,7 +10,7 @@ import { useParams } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import { useKibana } from '../../utils/kibana_react'; import { usePluginContext } from '../../hooks/use_plugin_context'; import { useFetchSloDetails } from '../../hooks/slo/use_fetch_slo_details'; diff --git a/x-pack/plugins/observability/public/pages/slos/components/slo_list_item.tsx b/x-pack/plugins/observability/public/pages/slos/components/slo_list_item.tsx index f352eef42794c..7988f9a4498ba 100644 --- a/x-pack/plugins/observability/public/pages/slos/components/slo_list_item.tsx +++ b/x-pack/plugins/observability/public/pages/slos/components/slo_list_item.tsx @@ -31,7 +31,7 @@ import type { ActiveAlerts } from '../../../hooks/slo/use_fetch_active_alerts'; import type { SloRule } from '../../../hooks/slo/use_fetch_rules_for_slo'; import { useGetFilteredRuleTypes } from '../../../hooks/use_get_filtered_rule_types'; import type { RulesParams } from '../../../locators/rules'; -import { paths } from '../../../routes/paths'; +import { paths } from '../../../../common/locators/paths'; import { useKibana } from '../../../utils/kibana_react'; import { transformCreateSLOFormToCreateSLOInput, diff --git a/x-pack/plugins/observability/public/pages/slos/slos.test.tsx b/x-pack/plugins/observability/public/pages/slos/slos.test.tsx index 7f85774f69300..9f16cb39b9a0c 100644 --- a/x-pack/plugins/observability/public/pages/slos/slos.test.tsx +++ b/x-pack/plugins/observability/public/pages/slos/slos.test.tsx @@ -23,7 +23,7 @@ import { SlosPage } from './slos'; import { emptySloList, sloList } from '../../data/slo/slo'; import { historicalSummaryData } from '../../data/slo/historical_summary_data'; import { useCapabilities } from '../../hooks/slo/use_capabilities'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), diff --git a/x-pack/plugins/observability/public/pages/slos/slos.tsx b/x-pack/plugins/observability/public/pages/slos/slos.tsx index 613e10b862abf..bae9f72b168a6 100644 --- a/x-pack/plugins/observability/public/pages/slos/slos.tsx +++ b/x-pack/plugins/observability/public/pages/slos/slos.tsx @@ -19,7 +19,7 @@ import { SloList } from './components/slo_list'; import { AutoRefreshButton } from './components/auto_refresh_button'; import { HeaderTitle } from './components/header_title'; import { FeedbackButton } from '../../components/slo/feedback_button/feedback_button'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; export function SlosPage() { const { diff --git a/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.test.tsx b/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.test.tsx index a2e4b95e55b00..f4b7e1ec6225c 100644 --- a/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.test.tsx +++ b/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.test.tsx @@ -16,7 +16,7 @@ import { useLicense } from '../../hooks/use_license'; import { SlosWelcomePage } from './slos_welcome'; import { emptySloList, sloList } from '../../data/slo/slo'; import { useCapabilities } from '../../hooks/slo/use_capabilities'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; jest.mock('@kbn/observability-shared-plugin/public'); jest.mock('../../utils/kibana_react'); diff --git a/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.tsx b/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.tsx index 9009a18ce9813..5649a577c5e87 100644 --- a/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.tsx +++ b/x-pack/plugins/observability/public/pages/slos_welcome/slos_welcome.tsx @@ -23,7 +23,7 @@ import { useLicense } from '../../hooks/use_license'; import { usePluginContext } from '../../hooks/use_plugin_context'; import { useCapabilities } from '../../hooks/slo/use_capabilities'; import { useFetchSloList } from '../../hooks/slo/use_fetch_slo_list'; -import { paths } from '../../routes/paths'; +import { paths } from '../../../common/locators/paths'; import illustration from './assets/illustration.svg'; import { useFetchSloGlobalDiagnosis } from '../../hooks/slo/use_fetch_global_diagnosis'; diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index bff1d1903f64d..f7c56d5d76e35 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -70,7 +70,7 @@ import { OVERVIEW_PATH, RULES_PATH, SLOS_PATH, -} from './routes/paths'; +} from '../common/locators/paths'; export interface ConfigSchema { unsafe: { diff --git a/x-pack/plugins/observability/public/routes/routes.tsx b/x-pack/plugins/observability/public/routes/routes.tsx index 433e674b73935..f04b98227e78a 100644 --- a/x-pack/plugins/observability/public/routes/routes.tsx +++ b/x-pack/plugins/observability/public/routes/routes.tsx @@ -35,7 +35,7 @@ import { SLO_CREATE_PATH, SLO_DETAIL_PATH, SLO_EDIT_PATH, -} from './paths'; +} from '../../common/locators/paths'; // Note: React Router DOM component was not working here // so I've recreated this simple version for this purpose. 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 51d826b852693..0c3b53c269371 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 @@ -8,13 +8,14 @@ import { schema } from '@kbn/config-schema'; import { extractReferences, injectReferences } from '@kbn/data-plugin/common'; import { i18n } from '@kbn/i18n'; -import { IRuleTypeAlerts } from '@kbn/alerting-plugin/server'; +import { IRuleTypeAlerts, GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server'; import { IBasePath, Logger } from '@kbn/core/server'; import { legacyExperimentalFieldMap } from '@kbn/alerts-as-data-utils'; import { createLifecycleExecutor, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; 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 { Comparator } from '../../../../common/threshold_rule/types'; import { OBSERVABILITY_THRESHOLD_RULE_TYPE_ID } from '../../../../common/constants'; @@ -180,5 +181,8 @@ export function thresholdRuleType( }, producer: observabilityFeatureId, alerts: MetricsRulesTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => { + return paths.observability.ruleDetails(rule.id); + }, }; } From 0d301ef0badc3016bfac299a2784eaa25522b261 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 13:04:40 +0200 Subject: [PATCH 2/8] Configure observability rule URL for APM rule types --- .../rule_types/anomaly/register_anomaly_rule_type.ts | 10 +++++++++- .../error_count/register_error_count_rule_type.ts | 4 ++++ .../register_transaction_duration_rule_type.ts | 4 ++++ .../register_transaction_error_rate_rule_type.ts | 4 ++++ x-pack/plugins/observability/common/index.ts | 2 ++ .../rules/threshold/register_threshold_rule_type.ts | 5 ++--- 6 files changed, 25 insertions(+), 4 deletions(-) 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/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/threshold/register_threshold_rule_type.ts b/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts index 0c3b53c269371..982691002b831 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 @@ -181,8 +181,7 @@ export function thresholdRuleType( }, producer: observabilityFeatureId, alerts: MetricsRulesTypeAlertDefinition, - getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => { - return paths.observability.ruleDetails(rule.id); - }, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + paths.observability.ruleDetails(rule.id), }; } From d8058025c8cc4254fa4adbf4812e2b1e0809172a Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 13:09:58 +0200 Subject: [PATCH 3/8] Configure observability rule URL for infra rule types --- .../register_inventory_metric_threshold_rule_type.ts | 5 ++++- .../log_threshold/register_log_threshold_rule_type.ts | 5 ++++- .../metric_anomaly/register_metric_anomaly_rule_type.ts | 4 ++++ .../register_metric_threshold_rule_type.ts | 9 ++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) 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), }); } From 54f353b3d337753b33843c399d8abb3ff12cb188 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 13:18:29 +0200 Subject: [PATCH 4/8] Configure observability rule URL for observability rule types --- .../server/lib/rules/slo_burn_rate/register.ts | 5 ++++- .../lib/rules/threshold/register_threshold_rule_type.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) 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 146e4682c105d..2daf972399aa1 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 { @@ -84,6 +85,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 982691002b831..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'; @@ -182,6 +185,6 @@ export function thresholdRuleType( producer: observabilityFeatureId, alerts: MetricsRulesTypeAlertDefinition, getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => - paths.observability.ruleDetails(rule.id), + observabilityPaths.ruleDetails(rule.id), }; } From 02b611543692bccb3a4a81aff9e1fb742bbd8c88 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 13:52:58 +0200 Subject: [PATCH 5/8] 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), }); From 78834c9cca37328a1d411ae8beb3827af760c1fc Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 10 Aug 2023 15:42:27 +0200 Subject: [PATCH 6/8] Add getViewInAppRelativeUrl to monitor status rule --- .../alert_rules/status_rule/monitor_status_rule.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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..d0bb10c5a7806 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,9 +4,15 @@ * 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 { createLifecycleRuleTypeFactory, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; +import { observabilityPaths } from '@kbn/observability-plugin/common'; +import { + createLifecycleRuleTypeFactory, + GetViewInAppRelativeUrlFnOpts, + IRuleDataClient, +} from '@kbn/rule-registry-plugin/server'; import { SyntheticsPluginsSetupDependencies, SyntheticsServerSetup } from '../../types'; import { DOWN_LABEL, getMonitorAlertDocument, getMonitorSummary } from './message_utils'; import { @@ -155,5 +161,7 @@ export const registerSyntheticsStatusCheckRule = ( }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); }; From 4861ac63ffc41b5369b2ae2702a09c566677a66c Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 10 Aug 2023 16:21:59 +0200 Subject: [PATCH 7/8] Configure observability rule URL for tls rule type --- .../synthetics/server/alert_rules/tls_rule/tls_rule.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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..8ff0a6b79f9ad 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,14 +4,20 @@ * 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 { createLifecycleRuleTypeFactory, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; +import { + createLifecycleRuleTypeFactory, + GetViewInAppRelativeUrlFnOpts, + IRuleDataClient, +} from '@kbn/rule-registry-plugin/server'; import { asyncForEach } from '@kbn/std'; import { ALERT_REASON, ALERT_UUID } from '@kbn/rule-data-utils'; 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 +154,7 @@ export const registerSyntheticsTLSCheckRule = ( return { state: updateState(ruleState, foundCerts) }; }, alerts: UptimeRuleTypeAlertDefinition, + getViewInAppRelativeUrl: ({ rule }: GetViewInAppRelativeUrlFnOpts<{}>) => + observabilityPaths.ruleDetails(rule.id), }); }; From 898189f7b40d1bd00b454ac306aa80d1a662043e Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 10 Aug 2023 16:55:23 +0200 Subject: [PATCH 8/8] Fix type --- .../server/alert_rules/status_rule/monitor_status_rule.ts | 7 ++----- .../synthetics/server/alert_rules/tls_rule/tls_rule.ts | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) 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 d0bb10c5a7806..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 @@ -7,12 +7,9 @@ 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, - GetViewInAppRelativeUrlFnOpts, - IRuleDataClient, -} from '@kbn/rule-registry-plugin/server'; +import { createLifecycleRuleTypeFactory, IRuleDataClient } from '@kbn/rule-registry-plugin/server'; import { SyntheticsPluginsSetupDependencies, SyntheticsServerSetup } from '../../types'; import { DOWN_LABEL, getMonitorAlertDocument, getMonitorSummary } from './message_utils'; import { 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 8ff0a6b79f9ad..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 @@ -6,11 +6,8 @@ */ import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; -import { - createLifecycleRuleTypeFactory, - GetViewInAppRelativeUrlFnOpts, - IRuleDataClient, -} from '@kbn/rule-registry-plugin/server'; +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'; import {