[8.12] Deprecate feature flag for Log threshold alert details page (#172554) (#172775)

# Backport

This will backport the following commits from `main` to `8.12`:
- [Deprecate feature flag for Log threshold alert details page
(#172554)](https://github.com/elastic/kibana/pull/172554)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Bena
Kansara","email":"69037875+benakansara@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-12-07T07:35:01Z","message":"Deprecate
feature flag for Log threshold alert details page (#172554)\n\nResolves
https://github.com/elastic/kibana/issues/172379\r\n\r\n- Deprecates
following feature flag used for enabling/disabling Log\r\nthreshold
alert details
page:\r\n```\r\nxpack.observability.unsafe.alertDetails.logs.enabled\r\n```\r\n-
Removes usage of this flag from code.\r\n- Adding this flag in
`kibana.yml` will generate following warning:\r\n```\r\n[WARN
][config.deprecation] You no longer need to configure
\"xpack.observability.unsafe.alertDetails.logs.enabled\".\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6628232433c0144f7564b22d8e6d2941425431ae","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.12.0","Team:obs-ux-management","v8.13.0"],"number":172554,"url":"https://github.com/elastic/kibana/pull/172554","mergeCommit":{"message":"Deprecate
feature flag for Log threshold alert details page (#172554)\n\nResolves
https://github.com/elastic/kibana/issues/172379\r\n\r\n- Deprecates
following feature flag used for enabling/disabling Log\r\nthreshold
alert details
page:\r\n```\r\nxpack.observability.unsafe.alertDetails.logs.enabled\r\n```\r\n-
Removes usage of this flag from code.\r\n- Adding this flag in
`kibana.yml` will generate following warning:\r\n```\r\n[WARN
][config.deprecation] You no longer need to configure
\"xpack.observability.unsafe.alertDetails.logs.enabled\".\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6628232433c0144f7564b22d8e6d2941425431ae"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172554","number":172554,"mergeCommit":{"message":"Deprecate
feature flag for Log threshold alert details page (#172554)\n\nResolves
https://github.com/elastic/kibana/issues/172379\r\n\r\n- Deprecates
following feature flag used for enabling/disabling Log\r\nthreshold
alert details
page:\r\n```\r\nxpack.observability.unsafe.alertDetails.logs.enabled\r\n```\r\n-
Removes usage of this flag from code.\r\n- Adding this flag in
`kibana.yml` will generate following warning:\r\n```\r\n[WARN
][config.deprecation] You no longer need to configure
\"xpack.observability.unsafe.alertDetails.logs.enabled\".\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6628232433c0144f7564b22d8e6d2941425431ae"}}]}]
BACKPORT-->

Co-authored-by: Bena Kansara <69037875+benakansara@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-12-07 03:48:26 -05:00 committed by GitHub
parent f40e47cc10
commit 2a4a765073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 10 additions and 61 deletions

View file

@ -14,12 +14,6 @@ xpack.observability.unsafe.alertDetails.metrics.enabled: true
**[For Infrastructure rule types]** 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.logs.enabled: true
```
**[For Logs 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
```yaml
xpack.observability.unsafe.alertDetails.uptime.enabled: true
```

View file

@ -7,11 +7,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { i18n } from '@kbn/i18n';
import {
AlertsLocatorParams,
getAlertDetailsUrl,
getAlertUrl,
} from '@kbn/observability-plugin/common';
import { AlertsLocatorParams, getAlertDetailsUrl } from '@kbn/observability-plugin/common';
import {
ALERT_CONTEXT,
ALERT_EVALUATION_THRESHOLD,
@ -63,7 +59,6 @@ import { InfraBackendLibs } from '../../infra_types';
import {
AdditionalContext,
flattenAdditionalContext,
getAlertDetailsPageEnabledForApp,
getContextForRecoveredAlerts,
getGroupByObject,
unflattenObject,
@ -138,7 +133,6 @@ export const createLogThresholdExecutor = (libs: InfraBackendLibs) =>
getAlertByAlertUuid,
} = services;
const { basePath, alertsLocator } = libs;
const config = libs.getAlertDetailsConfig();
const alertFactory: LogThresholdAlertFactory = (
id,
@ -189,15 +183,7 @@ export const createLogThresholdExecutor = (libs: InfraBackendLibs) =>
alert.scheduleActions(actionGroup, {
...sharedContext,
...context,
alertDetailsUrl: getAlertDetailsPageEnabledForApp(config, 'logs')
? getAlertDetailsUrl(libs.basePath, spaceId, alertUuid)
: await getAlertUrl(
alertUuid,
spaceId,
indexedStartedAt,
libs.alertsLocator,
libs.basePath.publicBaseUrl
),
alertDetailsUrl: getAlertDetailsUrl(libs.basePath, spaceId, alertUuid),
});
});
}
@ -254,7 +240,6 @@ export const createLogThresholdExecutor = (libs: InfraBackendLibs) =>
validatedParams,
getAlertByAlertUuid,
alertsLocator,
isAlertDetailsPageEnabled: getAlertDetailsPageEnabledForApp(config, 'logs'),
});
} catch (e) {
throw new Error(e);
@ -868,7 +853,6 @@ const processRecoveredAlerts = async ({
validatedParams,
getAlertByAlertUuid,
alertsLocator,
isAlertDetailsPageEnabled = false,
}: {
basePath: IBasePath;
getAlertStartedDate: (alertId: string) => string | null;
@ -881,7 +865,6 @@ const processRecoveredAlerts = async ({
alertUuid: string
) => Promise<Partial<ParsedTechnicalFields & ParsedExperimentalFields> | null> | null;
alertsLocator?: LocatorPublic<AlertsLocatorParams>;
isAlertDetailsPageEnabled?: boolean;
}) => {
const groupByKeysObjectForRecovered = getGroupByObject(
validatedParams.groupBy,
@ -898,15 +881,7 @@ const processRecoveredAlerts = async ({
const viewInAppUrl = addSpaceIdToPath(basePath.publicBaseUrl, spaceId, relativeViewInAppUrl);
const baseContext = {
alertDetailsUrl: isAlertDetailsPageEnabled
? getAlertDetailsUrl(basePath, spaceId, alertUuid)
: await getAlertUrl(
alertUuid,
spaceId,
indexedStartedAt,
alertsLocator,
basePath.publicBaseUrl
),
alertDetailsUrl: getAlertDetailsUrl(basePath, spaceId, alertUuid),
group: hasGroupBy(validatedParams) ? recoveredAlertId : null,
groupByKeys: groupByKeysObjectForRecovered[recoveredAlertId],
timestamp: startedAt.toISOString(),

View file

@ -77,7 +77,6 @@ describe('renderApp', () => {
const config = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
},

View file

@ -90,7 +90,6 @@ const params = {
const config: Subset<ConfigSchema> = {
unsafe: {
alertDetails: {
logs: { enabled: true },
metrics: { enabled: true },
uptime: { enabled: true },
},

View file

@ -53,7 +53,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({
slo: { enabled: false },
alertDetails: {
apm: { enabled: false },
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
observability: { enabled: false },

View file

@ -59,7 +59,6 @@ jest.mock('@kbn/triggers-actions-ui-plugin/public/common/lib/kibana/kibana_react
const config = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
},

View file

@ -48,7 +48,6 @@ describe('APMSection', () => {
const config = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
},

View file

@ -81,7 +81,6 @@ const withCore = makeDecorator({
const config: ConfigSchema = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
observability: { enabled: false },

View file

@ -40,7 +40,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({
slo: { enabled: false },
alertDetails: {
apm: { enabled: false },
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
observability: { enabled: false },

View file

@ -94,7 +94,7 @@ export interface ConfigSchema {
metrics: {
enabled: boolean;
};
logs: {
logs?: {
enabled: boolean;
};
uptime: {

View file

@ -31,7 +31,6 @@ import type { TopAlert } from '../typings/alerts';
const defaultConfig = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
},
@ -63,15 +62,10 @@ describe('isAlertDetailsEnabled', () => {
start: 1630587249674,
lastUpdated: 1630588131750,
} as unknown as TopAlert;
it('returns FALSE when logs: { enabled: false }', () => {
expect(isAlertDetailsEnabledPerApp(logsAlert, defaultConfig)).toBeFalsy();
});
it('returns TRUE when logs: { enabled: true }', () => {
it('returns TRUE when rule type is logs.alert.document.count', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: true },
metrics: { enabled: false },
uptime: { enabled: false },
},
@ -113,7 +107,6 @@ describe('isAlertDetailsEnabled', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
},
@ -159,7 +152,6 @@ describe('isAlertDetailsEnabled', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: true },
uptime: { enabled: false },
},
@ -201,7 +193,6 @@ describe('isAlertDetailsEnabled', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: true },
},
@ -243,7 +234,6 @@ describe('isAlertDetailsEnabled', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: true },
metrics: { enabled: true },
uptime: { enabled: true },
},
@ -255,7 +245,6 @@ describe('isAlertDetailsEnabled', () => {
const updatedConfig = {
unsafe: {
alertDetails: {
logs: { enabled: true },
metrics: { enabled: true },
uptime: { enabled: true },
},

View file

@ -9,12 +9,12 @@ import { ALERT_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'];
const ALLOWED_RULE_TYPES = ['apm.transaction_duration', 'logs.alert.document.count'];
const isUnsafeAlertDetailsFlag = (
subject: string
): subject is keyof ConfigSchema['unsafe']['alertDetails'] =>
['uptime', 'logs', 'metrics', 'observability'].includes(subject);
): subject is keyof Omit<ConfigSchema['unsafe']['alertDetails'], 'logs'> =>
['uptime', 'metrics', 'observability'].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.

View file

@ -28,7 +28,6 @@ export function KibanaReactStorybookDecorator(Story: ComponentType) {
const config: ConfigSchema = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
observability: { enabled: false },

View file

@ -32,7 +32,6 @@ export const data = dataPluginMock.createStartContract();
const defaultConfig: ConfigSchema = {
unsafe: {
alertDetails: {
logs: { enabled: false },
metrics: { enabled: false },
uptime: { enabled: false },
observability: { enabled: false },

View file

@ -36,8 +36,7 @@ const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
logs: schema.object({
// Enable it by default: https://github.com/elastic/kibana/issues/159945
enabled: schema.boolean({ defaultValue: true }),
enabled: schema.boolean({ defaultValue: false }),
}),
uptime: schema.object({
enabled: schema.boolean({ defaultValue: false }),
@ -71,6 +70,7 @@ export const config: PluginConfigDescriptor = {
},
},
schema: configSchema,
deprecations: ({ unused }) => [unused('unsafe.alertDetails.logs.enabled', { level: 'warning' })],
};
export type ObservabilityConfig = TypeOf<typeof configSchema>;