[8.12] Add fieldsForAAD to observability plugin rule types (#172809) (#172826)

# Backport

This will backport the following commits from `main` to `8.12`:
- [Add fieldsForAAD to observability plugin rule types
(#172809)](https://github.com/elastic/kibana/pull/172809)

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

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

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"maryam.saeidi@elastic.co"},"sourceCommit":{"committedDate":"2023-12-07T14:28:04Z","message":"Add
fieldsForAAD to observability plugin rule types (#172809)\n\nRelated to
#158324\r\n\r\n## Summary\r\n\r\nThis PR adds `fieldsForAAD` to the SLO
burn rate and Custom threshold\r\nrules to ensure conditional actions
can use fields related to
these\r\nrules.\r\n\r\n<img\r\nsrc=\"7cb31448-58cc-4bf6-b0da-cdc5e746ae60\"\r\nwidth=500
/>","sha":"6e69fdceec7db321601923c005063c17bf605c78","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","backport:prev-minor","Team:obs-ux-management","v8.13.0"],"number":172809,"url":"https://github.com/elastic/kibana/pull/172809","mergeCommit":{"message":"Add
fieldsForAAD to observability plugin rule types (#172809)\n\nRelated to
#158324\r\n\r\n## Summary\r\n\r\nThis PR adds `fieldsForAAD` to the SLO
burn rate and Custom threshold\r\nrules to ensure conditional actions
can use fields related to
these\r\nrules.\r\n\r\n<img\r\nsrc=\"7cb31448-58cc-4bf6-b0da-cdc5e746ae60\"\r\nwidth=500
/>","sha":"6e69fdceec7db321601923c005063c17bf605c78"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172809","number":172809,"mergeCommit":{"message":"Add
fieldsForAAD to observability plugin rule types (#172809)\n\nRelated to
#158324\r\n\r\n## Summary\r\n\r\nThis PR adds `fieldsForAAD` to the SLO
burn rate and Custom threshold\r\nrules to ensure conditional actions
can use fields related to
these\r\nrules.\r\n\r\n<img\r\nsrc=\"7cb31448-58cc-4bf6-b0da-cdc5e746ae60\"\r\nwidth=500
/>","sha":"6e69fdceec7db321601923c005063c17bf605c78"}}]}] BACKPORT-->

Co-authored-by: Maryam Saeidi <maryam.saeidi@elastic.co>
This commit is contained in:
Kibana Machine 2023-12-07 10:48:47 -05:00 committed by GitHub
parent 0db574a1c9
commit 555876a7e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -8,3 +8,5 @@
export const SLO_ID_FIELD = 'slo.id';
export const SLO_REVISION_FIELD = 'slo.revision';
export const SLO_INSTANCE_ID_FIELD = 'slo.instanceId';
export const SLO_BURN_RATE_AAD_FIELDS = [SLO_ID_FIELD, SLO_REVISION_FIELD, SLO_INSTANCE_ID_FIELD];

View file

@ -28,3 +28,12 @@ export const NO_DATA_ACTION = {
}
),
};
export const CUSTOM_THRESHOLD_AAD_FIELDS = [
'cloud.*',
'host.*',
'orchestrator.*',
'container.*',
'labels.*',
'tags',
];

View file

@ -40,7 +40,7 @@ import {
createCustomThresholdExecutor,
CustomThresholdLocators,
} from './custom_threshold_executor';
import { FIRED_ACTION, NO_DATA_ACTION } from './constants';
import { CUSTOM_THRESHOLD_AAD_FIELDS, FIRED_ACTION, NO_DATA_ACTION } from './constants';
import { ObservabilityConfig } from '../../..';
export const MetricsRulesTypeAlertDefinition: IRuleTypeAlerts = {
@ -110,6 +110,7 @@ export function thresholdRuleType(
name: i18n.translate('xpack.observability.threshold.ruleName', {
defaultMessage: 'Custom threshold (Beta)',
}),
fieldsForAAD: CUSTOM_THRESHOLD_AAD_FIELDS,
validate: {
params: schema.object(
{

View file

@ -14,6 +14,7 @@ import { createLifecycleExecutor } from '@kbn/rule-registry-plugin/server';
import { legacyExperimentalFieldMap } from '@kbn/alerts-as-data-utils';
import { IBasePath } from '@kbn/core/server';
import { LocatorPublic } from '@kbn/share-plugin/common';
import { SLO_BURN_RATE_AAD_FIELDS } from '../../../../common/field_names/slo';
import { AlertsLocatorParams, observabilityPaths, sloFeatureId } from '../../../../common';
import { SLO_RULE_REGISTRATION_CONTEXT } from '../../../common/constants';
@ -54,6 +55,7 @@ export function sloBurnRateRuleType(
name: i18n.translate('xpack.observability.slo.rules.burnRate.name', {
defaultMessage: 'SLO burn rate',
}),
fieldsForAAD: SLO_BURN_RATE_AAD_FIELDS,
validate: {
params: schema.object({
sloId: schema.string(),