From 75be08fb73dfd2bea7ca75720bcd8625f88f9b0e Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 12 Feb 2024 10:49:54 +0100 Subject: [PATCH 1/6] Deprecate custom threshold rule feature flag for the alert details page --- .../src/rule_types/o11y_rules.ts | 2 ++ x-pack/README.md | 6 ------ .../public/pages/alerts/alerts.test.tsx | 1 - x-pack/plugins/observability/public/plugin.ts | 2 +- .../public/utils/is_alert_details_enabled.ts | 17 ++++++++++++----- .../observability/public/utils/test_helper.tsx | 1 - x-pack/plugins/observability/server/index.ts | 1 + .../custom_threshold_executor.ts | 18 +++--------------- 8 files changed, 19 insertions(+), 29 deletions(-) diff --git a/packages/kbn-rule-data-utils/src/rule_types/o11y_rules.ts b/packages/kbn-rule-data-utils/src/rule_types/o11y_rules.ts index 844c8e994947c..0b870bc5a11fe 100644 --- a/packages/kbn-rule-data-utils/src/rule_types/o11y_rules.ts +++ b/packages/kbn-rule-data-utils/src/rule_types/o11y_rules.ts @@ -7,8 +7,10 @@ */ export const OBSERVABILITY_THRESHOLD_RULE_TYPE_ID = 'observability.rules.custom_threshold'; +export const SLO_BURN_RATE_RULE_TYPE_ID = 'slo.rules.burnRate'; export const METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.inventory.threshold'; +export const LOG_THRESHOLD_ALERT_TYPE_ID = 'logs.alert.document.count'; export enum ApmRuleType { ErrorCount = 'apm.error_rate', // ErrorRate was renamed to ErrorCount but the key is kept as `error_rate` for backwards-compat. diff --git a/x-pack/README.md b/x-pack/README.md index 255a4d3e2b6e8..421f16e8ca92a 100644 --- a/x-pack/README.md +++ b/x-pack/README.md @@ -20,12 +20,6 @@ xpack.observability.unsafe.alertDetails.uptime.enabled: true **[For Uptime rule type]** In Kibana configuration, will allow the user to navigate to the new Alert Details page, instead of the Alert Flyout when clicking on `View alert details` in the Alert table -```yaml -xpack.observability.unsafe.alertDetails.observability.enabled: true -``` - -**[For Observability Threshold rule type]** In Kibana configuration, will allow the user to navigate to the new Alert Details page, instead of the Alert Flyout when clicking on `View alert details` in the Alert table - # Development By default, Kibana will run with X-Pack installed as mentioned in the [contributing guide](../CONTRIBUTING.md). diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx index caf12f5bd6ea4..248deae214328 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx @@ -70,7 +70,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({ apm: { enabled: false }, metrics: { enabled: false }, uptime: { enabled: false }, - observability: { enabled: false }, }, }, aiAssistant: { diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index 5d6e825d83c43..2eaf319cb3f2d 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -103,7 +103,7 @@ export interface ConfigSchema { uptime: { enabled: boolean; }; - observability: { + observability?: { enabled: boolean; }; }; diff --git a/x-pack/plugins/observability/public/utils/is_alert_details_enabled.ts b/x-pack/plugins/observability/public/utils/is_alert_details_enabled.ts index 7672a67166069..3126afc7b5f9d 100644 --- a/x-pack/plugins/observability/public/utils/is_alert_details_enabled.ts +++ b/x-pack/plugins/observability/public/utils/is_alert_details_enabled.ts @@ -6,19 +6,26 @@ */ import { ALERT_RULE_TYPE_ID } from '@kbn/rule-data-utils'; +import { + ApmRuleType, + LOG_THRESHOLD_ALERT_TYPE_ID, + OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, + SLO_BURN_RATE_RULE_TYPE_ID, +} from '@kbn/rule-data-utils'; import type { ConfigSchema } from '../plugin'; import type { TopAlert } from '../typings/alerts'; const ALLOWED_RULE_TYPES = [ - 'apm.transaction_duration', - 'logs.alert.document.count', - 'slo.rules.burnRate', + ApmRuleType.TransactionDuration, + LOG_THRESHOLD_ALERT_TYPE_ID, + OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, + SLO_BURN_RATE_RULE_TYPE_ID, ]; const isUnsafeAlertDetailsFlag = ( subject: string -): subject is keyof Omit => - ['uptime', 'metrics', 'observability'].includes(subject); +): subject is keyof Omit => + ['uptime', 'metrics'].includes(subject); // We are mapping the ruleTypeId from the feature flag with the ruleTypeId from the alert // to know whether the feature flag is enabled or not. diff --git a/x-pack/plugins/observability/public/utils/test_helper.tsx b/x-pack/plugins/observability/public/utils/test_helper.tsx index 61fb7bbade53f..35ab846a79fcf 100644 --- a/x-pack/plugins/observability/public/utils/test_helper.tsx +++ b/x-pack/plugins/observability/public/utils/test_helper.tsx @@ -34,7 +34,6 @@ const defaultConfig: ConfigSchema = { alertDetails: { metrics: { enabled: false }, uptime: { enabled: false }, - observability: { enabled: false }, }, }, }; diff --git a/x-pack/plugins/observability/server/index.ts b/x-pack/plugins/observability/server/index.ts index 682d05e2f249f..07fb79a05f412 100644 --- a/x-pack/plugins/observability/server/index.ts +++ b/x-pack/plugins/observability/server/index.ts @@ -74,6 +74,7 @@ export const config: PluginConfigDescriptor = { deprecations: ({ unused }) => [ unused('unsafe.thresholdRule.enabled', { level: 'warning' }), unused('unsafe.alertDetails.logs.enabled', { level: 'warning' }), + unused('unsafe.alertDetails.observability.enabled', { level: 'warning' }), ], }; diff --git a/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.ts b/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.ts index b59c3f532daea..23eed517911d2 100644 --- a/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.ts +++ b/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.ts @@ -19,7 +19,7 @@ import { RecoveredActionGroup } from '@kbn/alerting-plugin/common'; import { IBasePath, Logger } from '@kbn/core/server'; import { LifecycleRuleExecutor } from '@kbn/rule-registry-plugin/server'; import { getEvaluationValues, getThreshold } from './lib/get_values'; -import { AlertsLocatorParams, getAlertUrl } from '../../../../common'; +import { AlertsLocatorParams, getAlertDetailsUrl } from '../../../../common'; import { getViewInAppUrl } from '../../../../common/custom_threshold_rule/get_view_in_app_url'; import { ObservabilityConfig } from '../../..'; import { FIRED_ACTIONS_ID, NO_DATA_ACTIONS_ID, UNGROUPED_FACTORY_KEY } from './constants'; @@ -278,13 +278,7 @@ export const createCustomThresholdExecutor = ({ scheduledActionsCount++; alert.scheduleActions(actionGroupId, { - alertDetailsUrl: await getAlertUrl( - alertUuid, - spaceId, - indexedStartedAt, - alertsLocator, - basePath.publicBaseUrl - ), + alertDetailsUrl: getAlertDetailsUrl(basePath, spaceId, alertUuid), group: groupByKeysObjectMapping[group], reason, timestamp, @@ -327,13 +321,7 @@ export const createCustomThresholdExecutor = ({ const additionalContext = getContextForRecoveredAlerts(alertHits); alert.setContext({ - alertDetailsUrl: await getAlertUrl( - alertUuid, - spaceId, - indexedStartedAt, - alertsLocator, - basePath.publicBaseUrl - ), + alertDetailsUrl: getAlertDetailsUrl(basePath, spaceId, alertUuid), group, timestamp: startedAt.toISOString(), viewInAppUrl: getViewInAppUrl({ From e0919ba4d829fc08e2f6132d4632b4b4ed23a74c Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 12 Feb 2024 15:09:43 +0100 Subject: [PATCH 2/6] Fix test --- .../rules/custom_threshold/custom_threshold_executor.test.ts | 2 +- .../observability/custom_threshold_rule/avg_pct_fired.ts | 4 +--- .../observability/custom_threshold_rule/avg_pct_no_data.ts | 4 +--- .../observability/custom_threshold_rule/avg_us_fired.ts | 3 +-- .../custom_threshold_rule/custom_eq_avg_bytes_fired.ts | 4 +--- .../custom_threshold_rule/documents_count_fired.ts | 4 +--- .../observability/custom_threshold_rule/group_by_fired.ts | 4 +--- .../observability/custom_threshold_rule/p99_pct_fired.ts | 4 +--- .../observability/custom_threshold_rule/rate_bytes_fired.ts | 4 +--- .../observability/custom_threshold_rule/group_by_fired.ts | 4 +--- 10 files changed, 10 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.test.ts b/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.test.ts index 51fc7e7227cdf..11054afbcb91f 100644 --- a/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.test.ts +++ b/x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.test.ts @@ -1400,7 +1400,7 @@ describe('The custom threshold alert type', () => { await execute(true); const recentAction = mostRecentAction(instanceID); expect(recentAction.action).toEqual({ - alertDetailsUrl: '', + alertDetailsUrl: 'http://localhost:5601/app/observability/alerts/mock-alert-uuid', reason: 'Average test.metric.3 reported no data in the last 1m', timestamp: STARTED_AT_MOCK_DATE.toISOString(), value: ['[NO DATA]', null], diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts index 929913f15f39f..f3d784d86d08a 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts @@ -5,7 +5,6 @@ * 2.0. */ -import moment from 'moment'; import { omit } from 'lodash'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { @@ -232,7 +231,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -240,7 +238,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Average system.cpu.user.pct is 250%, above the threshold of 50%. (duration: 5 mins, data view: ${DATA_VIEW_NAME})` diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts index 1b662f2af5aee..79d50d5bcf53f 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts @@ -6,7 +6,6 @@ */ import { omit } from 'lodash'; -import moment from 'moment'; import { Aggregators, Comparator, @@ -200,7 +199,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -208,7 +206,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( 'Average system.cpu.user.pct reported no data in the last 5m' diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts index 1a32a0af3612e..9adcba3a0acaa 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts @@ -210,7 +210,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action parameter: ruleType', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -218,7 +217,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Average span.self_time.sum.us is 10,000,000, above the threshold of 7,500,000. (duration: 5 mins, data view: ${DATA_VIEW_NAME})` diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts index d1c8a2927837c..5bacf710a9682 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts @@ -5,7 +5,6 @@ * 2.0. */ -import moment from 'moment'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { Aggregators, @@ -230,7 +229,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -238,7 +236,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Custom equation is 1, above the threshold of 0.9. (duration: 1 min, data view: ${DATA_VIEW})` diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts index 43029573defd8..dec612e4d7a92 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts @@ -6,7 +6,6 @@ */ import { omit } from 'lodash'; -import moment from 'moment'; import expect from '@kbn/expect'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { @@ -231,7 +230,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -239,7 +237,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts index 55f2d61be2b0e..748439e7eec60 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts @@ -5,7 +5,6 @@ * 2.0. */ -import moment from 'moment'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { Aggregators, @@ -251,7 +250,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -259,7 +257,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Average system.cpu.total.norm.pct is 80%, above or equal the threshold of 20%. (duration: 1 min, data view: ${DATA_VIEW}, group: host-0,container-0)` diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts index 942d025dd11f3..7e0fd56865c5e 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts @@ -5,7 +5,6 @@ * 2.0. */ -import moment from 'moment'; import { omit } from 'lodash'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { @@ -227,7 +226,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -235,7 +233,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `99th percentile of system.cpu.user.pct is 250%, above the threshold of 50%. (duration: 5 mins, data view: ${DATE_VIEW_NAME})` diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts index b76dd0c2581fc..41e0a664769d1 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts @@ -5,7 +5,6 @@ * 2.0. */ -import moment from 'moment'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { Aggregators, @@ -247,7 +246,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await waitForDocumentInIndex({ esClient, indexName: ALERT_ACTION_INDEX, @@ -255,7 +253,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `https://localhost:5601/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `https://localhost:5601/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Rate of system.network.in.bytes is 0.3 B/s, above or equal the threshold of 0.2 B/s. (duration: 1 min, data view: kbn-data-forge-fake_hosts.fake_hosts-*, group: host-0,container-0)` diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts index 264057cacff1c..f12fef06212b6 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts @@ -12,7 +12,6 @@ */ import { kbnTestConfig } from '@kbn/test'; -import moment from 'moment'; import { cleanup, generate, Dataset, PartialConfig } from '@kbn/data-forge'; import { Aggregators, @@ -238,7 +237,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should set correct action variables', async () => { - const rangeFrom = moment(startedAt).subtract('5', 'minute').toISOString(); const resp = await alertingApi.waitForDocumentInIndex<{ ruleType: string; alertDetailsUrl: string; @@ -252,7 +250,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - `${protocol}://${hostname}:${port}/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `${protocol}://${hostname}:${port}/app/observability/alerts/${alertId}` ); expect(resp.hits.hits[0]._source?.reason).eql( `Average system.cpu.total.norm.pct is 80%, above or equal the threshold of 20%. (duration: 1 min, data view: ${DATA_VIEW}, group: host-0)` From 345a16b552bab867ed80d2d956ed151eb3d86332 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 12 Feb 2024 16:19:24 +0100 Subject: [PATCH 3/6] Remove unused startedAt variable --- .../observability/custom_threshold_rule/avg_pct_fired.ts | 2 -- .../observability/custom_threshold_rule/avg_pct_no_data.ts | 2 -- .../observability/custom_threshold_rule/avg_us_fired.ts | 2 -- .../custom_threshold_rule/custom_eq_avg_bytes_fired.ts | 2 -- .../custom_threshold_rule/documents_count_fired.ts | 2 -- .../observability/custom_threshold_rule/group_by_fired.ts | 2 -- .../observability/custom_threshold_rule/p99_pct_fired.ts | 2 -- .../observability/custom_threshold_rule/rate_bytes_fired.ts | 2 -- .../observability/custom_threshold_rule/group_by_fired.ts | 2 -- 9 files changed, 18 deletions(-) diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts index f3d784d86d08a..96cb77e5f377c 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts @@ -54,7 +54,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -180,7 +179,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts index 79d50d5bcf53f..9e0dbc4faa88f 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_no_data.ts @@ -40,7 +40,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { await createDataView({ @@ -148,7 +147,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts index 9adcba3a0acaa..702eda6da85d6 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_us_fired.ts @@ -48,7 +48,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { synthtraceEsClient = await getSyntraceClient({ esClient, kibanaUrl }); @@ -159,7 +158,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts index 5bacf710a9682..5262db27ca272 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts @@ -41,7 +41,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -177,7 +176,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts index dec612e4d7a92..e45683795d323 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts @@ -44,7 +44,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -177,7 +176,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts index 748439e7eec60..3074f34c23334 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts @@ -40,7 +40,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -177,7 +176,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts index 7e0fd56865c5e..22155b2b88719 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/p99_pct_fired.ts @@ -54,7 +54,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -175,7 +174,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts index 41e0a664769d1..283d3fe1b2158 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/rate_bytes_fired.ts @@ -40,7 +40,6 @@ export default function ({ getService }: FtrProviderContext) { let actionId: string; let ruleId: string; let alertId: string; - let startedAt: string; before(async () => { dataForgeConfig = { @@ -173,7 +172,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts index f12fef06212b6..6638c7bef9d9d 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts @@ -30,7 +30,6 @@ export default function ({ getService }: FtrProviderContext) { const alertingApi = getService('alertingApi'); const dataViewApi = getService('dataViewApi'); let alertId: string; - let startedAt: string; describe('Custom Threshold rule - GROUP_BY - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; @@ -180,7 +179,6 @@ export default function ({ getService }: FtrProviderContext) { ruleId, }); alertId = (resp.hits.hits[0]._source as any)['kibana.alert.uuid']; - startedAt = (resp.hits.hits[0]._source as any)['kibana.alert.start']; expect(resp.hits.hits[0]._source).property( 'kibana.alert.rule.category', From 29183b515618644888cc3bc3726ca370524724dc Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Tue, 13 Feb 2024 17:17:46 +0100 Subject: [PATCH 4/6] Show beta badge in the alert details page title. --- .../public/components/experimental_badge.tsx | 13 +++++++++++++ .../pages/alert_details/components/page_title.tsx | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability/public/components/experimental_badge.tsx b/x-pack/plugins/observability/public/components/experimental_badge.tsx index 807886cbf5119..5a55d48a1999e 100644 --- a/x-pack/plugins/observability/public/components/experimental_badge.tsx +++ b/x-pack/plugins/observability/public/components/experimental_badge.tsx @@ -22,3 +22,16 @@ export function ExperimentalBadge() { /> ); } + +export function BetaBadge() { + return ( + + ); +} diff --git a/x-pack/plugins/observability/public/pages/alert_details/components/page_title.tsx b/x-pack/plugins/observability/public/pages/alert_details/components/page_title.tsx index 07f579d322630..2a4dc6d7ab6b5 100644 --- a/x-pack/plugins/observability/public/pages/alert_details/components/page_title.tsx +++ b/x-pack/plugins/observability/public/pages/alert_details/components/page_title.tsx @@ -5,6 +5,7 @@ * 2.0. */ +import moment from 'moment'; import React from 'react'; import { EuiFlexGroup, @@ -23,13 +24,13 @@ import { ALERT_FLAPPING, ALERT_RULE_CATEGORY, ALERT_RULE_TYPE_ID, + OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, TIMESTAMP, } from '@kbn/rule-data-utils'; -import moment from 'moment'; import { css } from '@emotion/react'; import { asDuration } from '../../../../common/utils/formatters'; import { TopAlert } from '../../../typings/alerts'; -import { ExperimentalBadge } from '../../../components/experimental_badge'; +import { BetaBadge, ExperimentalBadge } from '../../../components/experimental_badge'; import { METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID, METRIC_THRESHOLD_ALERT_TYPE_ID, @@ -60,11 +61,14 @@ export function PageTitle({ alert, alertStatus, dataTestSubj }: PageTitleProps) alert.fields[ALERT_RULE_TYPE_ID] === METRIC_THRESHOLD_ALERT_TYPE_ID || alert.fields[ALERT_RULE_TYPE_ID] === METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID; + const showBetaBadge = alert.fields[ALERT_RULE_TYPE_ID] === OBSERVABILITY_THRESHOLD_RULE_TYPE_ID; + return (
{pageTitleContent(alert.fields[ALERT_RULE_CATEGORY])} {showExperimentalBadge && } + {showBetaBadge && } From 4f9294f420fda604a46c865f88de3e544ff64ccf Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Tue, 13 Feb 2024 18:06:21 +0100 Subject: [PATCH 5/6] Fix translation id --- .../observability/public/components/experimental_badge.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability/public/components/experimental_badge.tsx b/x-pack/plugins/observability/public/components/experimental_badge.tsx index 5a55d48a1999e..59d16c35be5dd 100644 --- a/x-pack/plugins/observability/public/components/experimental_badge.tsx +++ b/x-pack/plugins/observability/public/components/experimental_badge.tsx @@ -29,7 +29,7 @@ export function BetaBadge() { label={i18n.translate('xpack.observability.experimentalBadgeLabel', { defaultMessage: 'Beta', })} - tooltipContent={i18n.translate('xpack.observability.experimentalBadgeDescription', { + tooltipContent={i18n.translate('xpack.observability.betaBadgeDescription', { defaultMessage: 'This functionality is in beta and is subject to change.', })} /> From 20c297a6e751ba350049ae3fc0e16a088d70d55c Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Tue, 13 Feb 2024 18:30:12 +0100 Subject: [PATCH 6/6] Fix translation id --- .../observability/public/components/experimental_badge.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability/public/components/experimental_badge.tsx b/x-pack/plugins/observability/public/components/experimental_badge.tsx index 59d16c35be5dd..19d48b449f691 100644 --- a/x-pack/plugins/observability/public/components/experimental_badge.tsx +++ b/x-pack/plugins/observability/public/components/experimental_badge.tsx @@ -26,7 +26,7 @@ export function ExperimentalBadge() { export function BetaBadge() { return (