Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.12] Deprecate feature flag for Custom threshold rule (#172584) #172792

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -57,7 +57,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({
uptime: { enabled: false },
observability: { enabled: false },
},
thresholdRule: { enabled: false },
},
aiAssistant: {
enabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const withCore = makeDecorator({
uptime: { enabled: false },
observability: { enabled: false },
},
thresholdRule: { enabled: false },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({
uptime: { enabled: false },
observability: { enabled: false },
},
thresholdRule: { enabled: false },
},
},
observabilityRuleTypeRegistry: createObservabilityRuleTypeRegistryMock(),
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface ConfigSchema {
enabled: boolean;
};
};
thresholdRule: {
thresholdRule?: {
enabled: boolean;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,52 +115,49 @@ export const registerObservabilityRuleTypes = async (
priority: 100,
});

if (config.unsafe.thresholdRule.enabled) {
observabilityRuleTypeRegistry.register({
id: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID,
description: i18n.translate(
'xpack.observability.customThreshold.rule.alertFlyout.alertDescription',
{
defaultMessage:
'Alert when any Observability data type reaches or exceeds a given value.',
}
),
iconClass: 'bell',
documentationUrl(docLinks) {
return `${docLinks.links.observability.customThreshold}`;
},
ruleParamsExpression: lazy(
() => import('../components/custom_threshold/custom_threshold_rule_expression')
),
validate: validateCustomThreshold,
defaultActionMessage: thresholdDefaultActionMessage,
defaultRecoveryMessage: thresholdDefaultRecoveryMessage,
requiresAppContext: false,
format: ({ fields }) => {
const searchConfiguration = fields[ALERT_RULE_PARAMETERS]?.searchConfiguration as
| SerializedSearchSourceFields
| undefined;
const criteria = fields[ALERT_RULE_PARAMETERS]?.criteria as MetricExpression[];
const metrics: CustomThresholdExpressionMetric[] =
criteria.length === 1 ? criteria[0].metrics : [];

const dataViewId = getDataViewId(searchConfiguration);
return {
reason: fields[ALERT_REASON] ?? '-',
link: getViewInAppUrl(
metrics,
fields[ALERT_START],
logExplorerLocator,
(searchConfiguration?.query as { query: string }).query,
dataViewId
),
hasBasePath: true,
};
},
alertDetailsAppSection: lazy(
() => import('../components/custom_threshold/components/alert_details_app_section')
),
priority: 5,
});
}
observabilityRuleTypeRegistry.register({
id: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID,
description: i18n.translate(
'xpack.observability.customThreshold.rule.alertFlyout.alertDescription',
{
defaultMessage: 'Alert when any Observability data type reaches or exceeds a given value.',
}
),
iconClass: 'bell',
documentationUrl(docLinks) {
return `${docLinks.links.observability.customThreshold}`;
},
ruleParamsExpression: lazy(
() => import('../components/custom_threshold/custom_threshold_rule_expression')
),
validate: validateCustomThreshold,
defaultActionMessage: thresholdDefaultActionMessage,
defaultRecoveryMessage: thresholdDefaultRecoveryMessage,
requiresAppContext: false,
format: ({ fields }) => {
const searchConfiguration = fields[ALERT_RULE_PARAMETERS]?.searchConfiguration as
| SerializedSearchSourceFields
| undefined;
const criteria = fields[ALERT_RULE_PARAMETERS]?.criteria as MetricExpression[];
const metrics: CustomThresholdExpressionMetric[] =
criteria.length === 1 ? criteria[0].metrics : [];

const dataViewId = getDataViewId(searchConfiguration);
return {
reason: fields[ALERT_REASON] ?? '-',
link: getViewInAppUrl(
metrics,
fields[ALERT_START],
logExplorerLocator,
(searchConfiguration?.query as { query: string }).query,
dataViewId
),
hasBasePath: true,
};
},
alertDetailsAppSection: lazy(
() => import('../components/custom_threshold/components/alert_details_app_section')
),
priority: 5,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function KibanaReactStorybookDecorator(Story: ComponentType) {
uptime: { enabled: false },
observability: { enabled: false },
},
thresholdRule: { enabled: false },
},
};

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/observability/public/utils/test_helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const defaultConfig: ConfigSchema = {
uptime: { enabled: false },
observability: { enabled: false },
},
thresholdRule: { enabled: false },
},
};

Expand Down
9 changes: 6 additions & 3 deletions x-pack/plugins/observability/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const configSchema = schema.object({
}),
thresholdRule: schema.object({
enabled: offeringBasedSchema({
serverless: schema.boolean({ defaultValue: true }),
traditional: schema.boolean({ defaultValue: true }),
serverless: schema.boolean({ defaultValue: false }),
traditional: schema.boolean({ defaultValue: false }),
}),
}),
}),
Expand All @@ -70,7 +70,10 @@ export const config: PluginConfigDescriptor = {
},
},
schema: configSchema,
deprecations: ({ unused }) => [unused('unsafe.alertDetails.logs.enabled', { level: 'warning' })],
deprecations: ({ unused }) => [
unused('unsafe.thresholdRule.enabled', { level: 'warning' }),
unused('unsafe.alertDetails.logs.enabled', { level: 'warning' }),
],
};

export type ObservabilityConfig = TypeOf<typeof configSchema>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,32 @@ export function registerRuleTypes(
sloBurnRateRuleType(createLifecycleRuleExecutorSLO, basePath, locators.alertsLocator)
);

// Threshold RULE
if (config.unsafe.thresholdRule.enabled) {
const ruleDataClientThreshold = ruleDataService.initializeIndex({
feature: observabilityFeatureId,
registrationContext: THRESHOLD_RULE_REGISTRATION_CONTEXT,
dataset: Dataset.alerts,
componentTemplateRefs: [],
componentTemplates: [
{
name: 'mappings',
mappings: mappingFromFieldMap({ ...legacyExperimentalFieldMap }, 'strict'),
},
],
});
const ruleDataClientThreshold = ruleDataService.initializeIndex({
feature: observabilityFeatureId,
registrationContext: THRESHOLD_RULE_REGISTRATION_CONTEXT,
dataset: Dataset.alerts,
componentTemplateRefs: [],
componentTemplates: [
{
name: 'mappings',
mappings: mappingFromFieldMap({ ...legacyExperimentalFieldMap }, 'strict'),
},
],
});

const createLifecycleRuleExecutorThreshold = createLifecycleExecutor(
logger.get('rules'),
ruleDataClientThreshold
);
const createLifecycleRuleExecutorThreshold = createLifecycleExecutor(
logger.get('rules'),
ruleDataClientThreshold
);

alertingPlugin.registerType(
thresholdRuleType(
createLifecycleRuleExecutorThreshold,
basePath,
config,
logger,
ruleDataClientThreshold,
locators
)
);
}
alertingPlugin.registerType(
thresholdRuleType(
createLifecycleRuleExecutorThreshold,
basePath,
config,
logger,
ruleDataClientThreshold,
locators
)
);
}
1 change: 0 additions & 1 deletion x-pack/test/alerting_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
'--xpack.alerting.healthCheck.interval="1s"',
'--xpack.alerting.rules.minimumScheduleInterval.value="1s"',
'--xpack.alerting.rules.run.alerts.max=20',
'--xpack.observability.unsafe.thresholdRule.enabled=true',
`--xpack.alerting.rules.run.actions.connectorTypeOverrides=${JSON.stringify([
{ id: 'test.capped', max: '1' },
])}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export default createTestConfig({
suiteTags: { exclude: ['skipSvlOblt'] },
services,
// add feature flags
kbnServerArgs: [
'--xpack.observability.unsafe.thresholdRule.enabled=true',
'--xpack.infra.enabled=true',
],
kbnServerArgs: ['--xpack.infra.enabled=true'],
// load tests in the index file
testFiles: [require.resolve('./index.feature_flags.ts')],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default createTestConfig({
kbnServerArgs: [
'--xpack.infra.enabled=true',
'--xpack.infra.featureFlags.customThresholdAlertsEnabled=true',
'--xpack.observability.unsafe.thresholdRule.enabled=true',
],
// load tests in the index file
testFiles: [require.resolve('./index.feature_flags.ts')],
Expand Down
Loading