Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type ManagementId =
| 'action_policies'
| 'execution_history'
| 'rules'
| 'rule_library'
| 'triggersActions'
| 'triggersActionsAlerts'
| 'triggersActionsConnectors'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export const AGENT_BUILDER_TRACING_USER_DATA_SETTING_ID = 'agentBuilder:tracing:

// Alerting settings
export const ALERTING_V2_ENABLED_SETTING_ID = 'alerting:v2:enabled';
export const ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID =
'alerting:v2:showClassicAlertsTable';

// Context engine settings
export const CONTEXT_ENGINE_ENABLED_SETTING_ID = 'contextEngine:enabled';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {

export const OBSERVABILITY_PROJECT_SETTINGS = [
settings.ALERTING_V2_ENABLED_SETTING_ID,
settings.ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID,
settings.DEFAULT_ROUTE_ID,
settings.OBSERVABILITY_ENABLE_COMPARISON_BY_DEFAULT_ID,
settings.OBSERVABILITY_APM_DEFAULT_SERVICE_ENVIRONMENT_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

export const ALERTING_V2_ENABLED_SETTING_ID = 'alerting:v2:enabled';

/**
* Space-scoped. When Alerting v2 is enabled, controls whether the classic
* Observability alerts table remains in solution navigation.
*/
export const ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID =
'alerting:v2:showClassicAlertsTable';

export interface AlertingAdvancedSettingValueMap {
[ALERTING_V2_ENABLED_SETTING_ID]: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export { getAlertingV2ManagementNavPanel } from './get_management_nav_panel';
export {
isAlertingV2Enabled,
shouldShowAlertingV2CreateRuleFlyout,
shouldShowClassicObservabilityAlertsTable,
} from './is_alerting_v2_enabled';

export { normalizeTags } from './normalize_tags';
export { resolveArtifactId } from './resolve_artifact_id';
export { resolveTimeField, type ResolveTimeFieldParams } from './time_field';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { coreMock } from '@kbn/core/public/mocks';
import {
isAlertingV2Enabled,
shouldShowAlertingV2CreateRuleFlyout,
shouldShowClassicObservabilityAlertsTable,
} from './is_alerting_v2_enabled';

describe('isAlertingV2Enabled', () => {
Expand Down Expand Up @@ -87,3 +88,37 @@ describe('shouldShowAlertingV2CreateRuleFlyout', () => {
expect(shouldShowAlertingV2CreateRuleFlyout(core)).toBe(false);
});
});

describe('shouldShowClassicObservabilityAlertsTable', () => {
let core: CoreStart;

beforeEach(() => {
core = coreMock.createStart();
core.settings.globalClient.get = <T>(_key: string) => false as T;
core.settings.client.get = <T>(_key: string) => false as T;
});

it('returns true when alerting v2 is disabled', () => {
expect(shouldShowClassicObservabilityAlertsTable(core)).toBe(true);
});

it('returns false when alerting v2 is enabled and the space setting is off', () => {
core.settings.globalClient.get = <T>(_key: string) => true as T;

expect(shouldShowClassicObservabilityAlertsTable(core)).toBe(false);
});

it('returns true when alerting v2 is enabled and the space setting is on', () => {
core.settings.globalClient.get = <T>(_key: string) => true as T;
core.settings.client.get = <T>(_key: string) => true as T;

expect(shouldShowClassicObservabilityAlertsTable(core)).toBe(true);
});

it('returns false when alerting v2 is enabled and the space setting is unset', () => {
core.settings.globalClient.get = <T>(_key: string) => true as T;
core.settings.client.get = <T>(_key: string) => undefined as T;

expect(shouldShowClassicObservabilityAlertsTable(core)).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*/

import type { CoreStart } from '@kbn/core-lifecycle-browser';
import { ALERTING_V2_ENABLED_SETTING_ID } from '@kbn/alerting-v2-constants';
import {
ALERTING_V2_ENABLED_SETTING_ID,
ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID,
} from '@kbn/alerting-v2-constants';

/** Feature id from `@kbn/alerting-v2-plugin/common/feature_privileges`. */
const ALERTING_V2_RULES_FEATURE_ID = 'alerting_v2_rules';
Expand Down Expand Up @@ -46,3 +49,21 @@ export const isAlertingV2Enabled = (core: CoreStart): boolean => {
export const shouldShowAlertingV2CreateRuleFlyout = (core: CoreStart): boolean => {
return isAlertingV2Enabled(core) && hasAlertingV2RulesWriteCapability(core);
};

/**
* Returns whether the classic Observability alerts table should appear in
* solution navigation.
*
* Always shown while Alerting v2 is disabled. When v2 is enabled, shown only
* if the space-scoped `alerting:v2:showClassicAlertsTable` setting is true.
*/
export const shouldShowClassicObservabilityAlertsTable = (core: CoreStart): boolean => {
if (!isAlertingV2Enabled(core)) {
return true;
}

return (
core.settings.client.get<boolean>(ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID, false) ===
true
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
import type { UiSettingsParams } from '@kbn/core/types';
import {
ALERTING_V2_ENABLED_SETTING_ID,
ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID,
type AlertingAdvancedSettingId,
type AlertingAdvancedSettingValueMap,
} from '@kbn/alerting-v2-constants';
Expand Down Expand Up @@ -43,3 +44,25 @@ export const alertingAdvancedSettings = {
experimental: true,
},
} satisfies AlertingV2AdvancedSettingsRegistration;

/**
* Space-scoped settings. Registered via `uiSettings.register` (not
* `registerGlobal`) so each Kibana space can opt in independently.
*/
export const alertingSpaceAdvancedSettings: Record<string, UiSettingsParams<boolean>> = {
[ALERTING_V2_SHOW_CLASSIC_ALERTS_TABLE_SETTING_ID]: {
category: [ALERTING_V2_CATEGORY],
name: i18n.translate('xpack.alertingVTwo.showClassicAlertsTableSettingName', {
defaultMessage: 'Show classic alerts table',
}),
type: 'boolean',
value: false,
description: i18n.translate('xpack.alertingVTwo.showClassicAlertsTableSettingDescription', {
defaultMessage:
'Show the classic Observability alerts table in navigation. Only displays alerts from v1 alerting rules.',
}),
schema: schema.boolean(),
requiresPageReload: true,
experimental: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import {
ACTION_POLICY_EVENT_ACTIONS,
ACTION_POLICY_EVENT_PROVIDER,
} from '../lib/dispatcher/steps/constants';
import { alertingAdvancedSettings } from '../settings/advanced_settings';
import {
alertingAdvancedSettings,
alertingSpaceAdvancedSettings,
} from '../settings/advanced_settings';

/**
* Core platform setup-phase registrations (feature privileges, saved objects,
Expand Down Expand Up @@ -56,6 +59,7 @@ export function bindOnSetup({ bind }: ContainerModuleLoadOptions) {
const uiSettingsSetup = container.get(CoreSetup('uiSettings'));

uiSettingsSetup.registerGlobal(alertingAdvancedSettings);
uiSettingsSetup.register(alertingSpaceAdvancedSettings);

const eventLogService = container.get(
PluginSetup<AlertingServerSetupDependencies['eventLog']>('eventLog')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ dependsOn:
- '@kbn/app-header'
- '@kbn/core-chrome-app-menu-components'
- '@kbn/global-search-plugin'
- '@kbn/core-lifecycle-browser'
tags:
- plugin
- prod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export { getCoreVitalsComponent } from './pages/overview/components/sections/ux/
export { ObservabilityAlertSearchBar } from './components/alert_search_bar/get_alert_search_bar_lazy';
export { DatePicker } from './pages/overview/components/date_picker';
export { NightshiftNavigationIcon } from '@kbn/observability-shared-plugin/public';
export { getAlertsNavPanel } from './nav/get_alerts_nav_panel';

export type {
Stat,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { RootNodeDefinition } from '@kbn/core-chrome-browser';
import type { CoreStart } from '@kbn/core-lifecycle-browser';
import { i18n } from '@kbn/i18n';
import {
isAlertingV2Enabled,
shouldShowClassicObservabilityAlertsTable,
} from '@kbn/alerting-v2-utils';

const PANEL_ID = 'alerting';
const ALERTS_LINK = 'observability-overview:alerts' as const;
const ALERTS_ICON = 'warning';

/**
* Returns the solution-nav Alerts entry for Observability.
*
* When `alerting:v2:enabled` is false, returns a plain Alerts link.
* When true, returns a panel opener whose flyout contains Inbox
* (alerting v2 episodes), Alerts V1 (classic alerts), Notifications
* and Suppressions, and Operations.
*
* Spread into a navigation tree `body`:
*
* ```ts
* ...getAlertsNavPanel(core),
* ```
*/
export const getAlertsNavPanel = (core: CoreStart): RootNodeDefinition[] => {
if (!isAlertingV2Enabled(core)) {
return [{ link: ALERTS_LINK, icon: ALERTS_ICON }];
}

return [
{
id: PANEL_ID,
link: ALERTS_LINK,
icon: ALERTS_ICON,
renderAs: 'panelOpener',
children: [
{
breadcrumbStatus: 'hidden' as const,
children: [
{
link: 'management:episodes' as const,
title: i18n.translate('xpack.observability.nav.inbox', {
defaultMessage: 'Inbox',
}),
},
...(shouldShowClassicObservabilityAlertsTable(core)
? [
{
link: ALERTS_LINK,
title: i18n.translate('xpack.observability.nav.alertsV1', {
defaultMessage: 'Alerts V1',
}),
},
]
: []),
],
},
{
title: i18n.translate('xpack.observability.nav.ruleManagement', {
defaultMessage: 'Rule Management',
}),
breadcrumbStatus: 'hidden' as const,
children: [
{ link: 'management:rules' as const },
{ link: 'management:rule_library' as const },
],
},
{
title: i18n.translate('xpack.observability.nav.notificationsAndSuppressions', {
defaultMessage: 'Notifications and Suppressions',
}),
breadcrumbStatus: 'hidden' as const,
children: [
{ link: 'management:action_policies' as const },
{ link: 'management:maintenanceWindows' as const },
],
},
{
title: i18n.translate('xpack.observability.nav.operations', {
defaultMessage: 'Operations',
}),
breadcrumbStatus: 'hidden' as const,
children: [{ link: 'management:execution_history' as const }],
},
],
},
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { combineLatest, map, of } from 'rxjs';
import { AIChatExperience } from '@kbn/ai-assistant-common';
import { AI_CHAT_EXPERIENCE_TYPE } from '@kbn/management-settings-ids';
import { getAlertingV2ManagementNavPanel } from '@kbn/alerting-v2-utils';

import { getWorkflowsNavPanel } from '@kbn/deeplinks-workflows';
import { EVALS_APP_ID } from '@kbn/deeplinks-evals';
import { STREAMS_SIGNIFICANT_EVENTS_AVAILABLE_FLAG } from '@kbn/significant-events-plugin/common';
import type { Location } from 'history';
import { NightshiftNavigationIcon } from '@kbn/observability-shared-plugin/public';
import { getAlertsNavPanel } from './nav/get_alerts_nav_panel';
import type { ObservabilityPublicPluginsStart } from './plugin';

const title = i18n.translate(
Expand Down Expand Up @@ -96,12 +98,10 @@ function createNavTree({
icon: 'flask',
},
...getWorkflowsNavPanel(coreStart),
{
link: 'observability-overview:alerts',
icon: 'warning',
},
...getAlertsNavPanel(coreStart),
{
link: 'observability-overview:cases',

children: [
{
link: 'observability-overview:cases_configure',
Expand Down
Loading
Loading