Update view rule details link for the threshold rule (#163091)

Closes #162890

## Summary

In this PR, I am updating the `View rule in Kibana` only for the new
threshold rule, I will do the same for the rest of the rules in the
following
[ticket](https://github.com/elastic/actionable-observability/issues/13).

<img
src="3fdeaed1-ce79-4518-af44-47418f09b3d3"
width=500 />


## 🧪 How to test

- Make sure `xpack.observability.unsafe.thresholdRule.enabled` is true
in Kibana yaml
- Create a threshold rule with an email connector
- In the email, check the `View rule in Kibana`, it should open the
observability rule details page
This commit is contained in:
Maryam Saeidi 2023-08-04 15:47:34 +02:00 committed by GitHub
parent 04b3d1741c
commit 08559a8d21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 36 additions and 31 deletions

View file

@ -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';

View file

@ -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';

View file

@ -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 {

View file

@ -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';

View file

@ -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';

View file

@ -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();

View file

@ -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,

View file

@ -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();

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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<CreateSLOForm>;

View file

@ -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;

View file

@ -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';

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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,

View file

@ -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'),

View file

@ -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 {

View file

@ -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');

View file

@ -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';

View file

@ -70,7 +70,7 @@ import {
OVERVIEW_PATH,
RULES_PATH,
SLOS_PATH,
} from './routes/paths';
} from '../common/locators/paths';
export interface ConfigSchema {
unsafe: {

View file

@ -35,7 +35,7 @@ import {
SLO_CREATE_PATH,
SLO_DETAIL_PATH,
SLO_EDIT_PATH,
} from './paths';
} from '../../common/locators/paths';
// Note: React Router DOM <Redirect> component was not working here
// so I've recreated this simple version for this purpose.

View file

@ -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);
},
};
}