From 0c2d483d19528eb970ba73dca4462a2eb1865239 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 7 Sep 2023 09:47:53 +0200 Subject: [PATCH] Rename customMetric to metrics in the custom threshold rule criteria (#165719) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #163819 ## Summary This PR renames customMetric to metrics in the custom threshold rule criteria to have a cleaner API for this rule, considering that custom aggregation is now the default option. ### 🧪 How to test - Create a custom threshold rule and ensure the preview is working fine - Check the related saved object and ensure the data is saved as shown above - Make sure the related alerts are generated as expected --- .../common/threshold_rule/types.ts | 4 ++-- .../custom_equation_editor.stories.tsx | 2 +- .../custom_equation_editor.tsx | 14 ++++++------- .../custom_equation/metric_row_with_agg.tsx | 4 ++-- .../components/custom_equation/types.ts | 6 +++--- .../threshold/components/validation.tsx | 20 +++++++++---------- .../hooks/use_metrics_explorer_chart_data.ts | 11 +++++----- .../threshold/threshold_rule_expression.tsx | 2 +- .../public/components/threshold/types.ts | 4 ++-- .../lib/create_custom_metrics_aggregations.ts | 10 +++++----- .../lib/rules/threshold/lib/metric_query.ts | 2 +- .../threshold/register_threshold_rule_type.ts | 6 +++--- .../translations/translations/fr-FR.json | 3 --- .../translations/translations/ja-JP.json | 3 --- .../translations/translations/zh-CN.json | 3 --- .../threshold_rule/avg_pct_fired.ts | 4 ++-- .../threshold_rule/avg_pct_no_data.ts | 4 ++-- .../threshold_rule/avg_us_fired.ts | 4 ++-- .../custom_eq_avg_bytes_fired.ts | 4 ++-- .../threshold_rule/documents_count_fired.ts | 4 ++-- .../threshold_rule/group_by_fired.ts | 4 ++-- .../observability/threshold_rule_data_view.ts | 2 +- .../threshold_rule/avg_pct_fired.ts | 4 ++-- .../threshold_rule/avg_pct_no_data.ts | 4 ++-- .../custom_eq_avg_bytes_fired.ts | 4 ++-- .../threshold_rule/documents_count_fired.ts | 4 ++-- .../threshold_rule/group_by_fired.ts | 4 ++-- 27 files changed, 66 insertions(+), 74 deletions(-) diff --git a/x-pack/plugins/observability/common/threshold_rule/types.ts b/x-pack/plugins/observability/common/threshold_rule/types.ts index 6511a2cb280a5..66e058dfad8cf 100644 --- a/x-pack/plugins/observability/common/threshold_rule/types.ts +++ b/x-pack/plugins/observability/common/threshold_rule/types.ts @@ -234,7 +234,7 @@ export type CustomMetricAggTypes = Exclude< Aggregators.CUSTOM | Aggregators.RATE | Aggregators.P95 | Aggregators.P99 >; -export interface MetricExpressionCustomMetric { +export interface CustomThresholdExpressionMetric { name: string; aggType: CustomMetricAggTypes; field?: string; @@ -243,7 +243,7 @@ export interface MetricExpressionCustomMetric { export interface CustomMetricExpressionParams extends BaseMetricExpressionParams { aggType: Aggregators.CUSTOM; - customMetrics: MetricExpressionCustomMetric[]; + metrics: CustomThresholdExpressionMetric[]; equation?: string; label?: string; } diff --git a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.stories.tsx b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.stories.tsx index 7cea506155818..f7480aa1de513 100644 --- a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.stories.tsx +++ b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.stories.tsx @@ -115,7 +115,7 @@ CustomEquationEditorWithEquationErrors.args = { expression: { ...BASE_ARGS.expression, equation: 'Math.round(A / B)', - customMetrics: [ + metrics: [ { name: 'A', aggType: Aggregators.AVERAGE, field: 'system.cpu.user.pct' }, { name: 'B', aggType: Aggregators.MAX, field: 'system.cpu.cores' }, ], diff --git a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.tsx b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.tsx index 8dbb44eda71dd..ed3dc975b2d07 100644 --- a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.tsx +++ b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/custom_equation_editor.tsx @@ -25,7 +25,7 @@ import { OMITTED_AGGREGATIONS_FOR_CUSTOM_METRICS } from '../../../../../common/t import { Aggregators, CustomMetricAggTypes, - MetricExpressionCustomMetric, + CustomThresholdExpressionMetric, } from '../../../../../common/threshold_rule/types'; import { MetricExpression } from '../../types'; @@ -58,7 +58,7 @@ export function CustomEquationEditor({ dataView, }: CustomEquationEditorProps) { const [customMetrics, setCustomMetrics] = useState( - expression?.customMetrics ?? [NEW_METRIC] + expression?.metrics ?? [NEW_METRIC] ); const [customEqPopoverOpen, setCustomEqPopoverOpen] = useState(false); const [equation, setEquation] = useState(expression?.equation || undefined); @@ -69,7 +69,7 @@ export function CustomEquationEditor({ const currentVars = previous?.map((m) => m.name) ?? []; const name = first(xor(VAR_NAMES, currentVars))!; const nextMetrics = [...(previous || []), { ...NEW_METRIC, name }]; - debouncedOnChange({ ...expression, customMetrics: nextMetrics, equation }); + debouncedOnChange({ ...expression, metrics: nextMetrics, equation }); return nextMetrics; }); }, [debouncedOnChange, equation, expression]); @@ -79,7 +79,7 @@ export function CustomEquationEditor({ setCustomMetrics((previous) => { const nextMetrics = previous?.filter((row) => row.name !== name) ?? [NEW_METRIC]; const finalMetrics = (nextMetrics.length && nextMetrics) || [NEW_METRIC]; - debouncedOnChange({ ...expression, customMetrics: finalMetrics, equation }); + debouncedOnChange({ ...expression, metrics: finalMetrics, equation }); return finalMetrics; }); }, @@ -87,10 +87,10 @@ export function CustomEquationEditor({ ); const handleChange = useCallback( - (metric: MetricExpressionCustomMetric) => { + (metric: CustomThresholdExpressionMetric) => { setCustomMetrics((previous) => { const nextMetrics = previous?.map((m) => (m.name === metric.name ? metric : m)); - debouncedOnChange({ ...expression, customMetrics: nextMetrics, equation }); + debouncedOnChange({ ...expression, metrics: nextMetrics, equation }); return nextMetrics; }); }, @@ -100,7 +100,7 @@ export function CustomEquationEditor({ const handleEquationChange = useCallback( (e: React.ChangeEvent) => { setEquation(e.target.value); - debouncedOnChange({ ...expression, customMetrics, equation: e.target.value }); + debouncedOnChange({ ...expression, metrics: customMetrics, equation: e.target.value }); }, [debouncedOnChange, expression, customMetrics] ); diff --git a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/metric_row_with_agg.tsx b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/metric_row_with_agg.tsx index 5b0925ea27dd3..7d8ab629e6e16 100644 --- a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/metric_row_with_agg.tsx +++ b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/metric_row_with_agg.tsx @@ -103,8 +103,8 @@ export function MetricRowWithAgg({ [name, aggType, onChange] ); - const isAggInvalid = get(errors, ['customMetrics', name, 'aggType']) != null; - const isFieldInvalid = get(errors, ['customMetrics', name, 'field']) != null || !field; + const isAggInvalid = get(errors, ['metrics', name, 'aggType']) != null; + const isFieldInvalid = get(errors, ['metrics', name, 'field']) != null || !field; return ( <> diff --git a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/types.ts b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/types.ts index abc63849ad1d1..d7c4096753763 100644 --- a/x-pack/plugins/observability/public/components/threshold/components/custom_equation/types.ts +++ b/x-pack/plugins/observability/public/components/threshold/components/custom_equation/types.ts @@ -5,10 +5,10 @@ * 2.0. */ import { AggregationType, IErrorObject } from '@kbn/triggers-actions-ui-plugin/public'; -import { MetricExpressionCustomMetric } from '../../../../../common/threshold_rule/types'; +import { CustomThresholdExpressionMetric } from '../../../../../common/threshold_rule/types'; import { MetricExpression } from '../../types'; -export type CustomMetrics = MetricExpression['customMetrics']; +export type CustomMetrics = MetricExpression['metrics']; export interface AggregationTypes { [x: string]: AggregationType; @@ -27,7 +27,7 @@ export interface MetricRowBaseProps { onDelete: (name: string) => void; disableDelete: boolean; disableAdd: boolean; - onChange: (metric: MetricExpressionCustomMetric) => void; + onChange: (metric: CustomThresholdExpressionMetric) => void; aggregationTypes: AggregationTypes; errors: IErrorObject; } diff --git a/x-pack/plugins/observability/public/components/threshold/components/validation.tsx b/x-pack/plugins/observability/public/components/threshold/components/validation.tsx index 2d72c1e090869..8917e8dac2f35 100644 --- a/x-pack/plugins/observability/public/components/threshold/components/validation.tsx +++ b/x-pack/plugins/observability/public/components/threshold/components/validation.tsx @@ -49,8 +49,8 @@ export function validateMetricThreshold({ threshold1: string[]; }; metric: string[]; - customMetricsError?: string; - customMetrics: Record; + metricsError?: string; + metrics: Record; equation?: string; }; } & { filterQuery?: string[]; searchConfiguration?: string[] } = {}; @@ -100,7 +100,7 @@ export function validateMetricThreshold({ threshold1: [], }, metric: [], - customMetrics: {}, + metrics: {}, }; if (!c.aggType) { errors[id].aggField.push( @@ -179,19 +179,19 @@ export function validateMetricThreshold({ } if (isCustomMetricExpressionParams(c)) { - if (!c.customMetrics || (c.customMetrics && c.customMetrics.length < 1)) { - errors[id].customMetricsError = i18n.translate( - 'xpack.observability.threshold.rule.alertFlyout.error.customMetricsError', + if (!c.metrics || (c.metrics && c.metrics.length < 1)) { + errors[id].metricsError = i18n.translate( + 'xpack.observability.threshold.rule.alertFlyout.error.metricsError', { defaultMessage: 'You must define at least 1 custom metric', } ); } else { - c.customMetrics.forEach((metric) => { + c.metrics.forEach((metric) => { const customMetricErrors: { aggType?: string; field?: string; filter?: string } = {}; if (!metric.aggType) { customMetricErrors.aggType = i18n.translate( - 'xpack.observability.threshold.rule.alertFlyout.error.customMetrics.aggTypeRequired', + 'xpack.observability.threshold.rule.alertFlyout.error.metrics.aggTypeRequired', { defaultMessage: 'Aggregation is required', } @@ -199,7 +199,7 @@ export function validateMetricThreshold({ } if (metric.aggType !== 'count' && !metric.field) { customMetricErrors.field = i18n.translate( - 'xpack.observability.threshold.rule.alertFlyout.error.customMetrics.fieldRequired', + 'xpack.observability.threshold.rule.alertFlyout.error.metrics.fieldRequired', { defaultMessage: 'Field is required', } @@ -213,7 +213,7 @@ export function validateMetricThreshold({ } } if (!isEmpty(customMetricErrors)) { - errors[id].customMetrics[metric.name] = customMetricErrors; + errors[id].metrics[metric.name] = customMetricErrors; } }); } diff --git a/x-pack/plugins/observability/public/components/threshold/hooks/use_metrics_explorer_chart_data.ts b/x-pack/plugins/observability/public/components/threshold/hooks/use_metrics_explorer_chart_data.ts index 75c1759e04287..26924ff0d3d8e 100644 --- a/x-pack/plugins/observability/public/components/threshold/hooks/use_metrics_explorer_chart_data.ts +++ b/x-pack/plugins/observability/public/components/threshold/hooks/use_metrics_explorer_chart_data.ts @@ -9,7 +9,7 @@ import DateMath from '@kbn/datemath'; import { DataViewBase } from '@kbn/es-query'; import { useMemo } from 'react'; import { MetricExplorerCustomMetricAggregations } from '../../../../common/threshold_rule/metrics_explorer'; -import { MetricExpressionCustomMetric } from '../../../../common/threshold_rule/types'; +import { CustomThresholdExpressionMetric } from '../../../../common/threshold_rule/types'; import { MetricExpression, TimeRange } from '../types'; import { useMetricsExplorerData } from './use_metrics_explorer_data'; @@ -43,8 +43,7 @@ export const useMetricsExplorerChartData = ( ? { aggregation: 'custom', custom_metrics: - expression?.customMetrics?.map(mapMetricThresholdMetricToMetricsExplorerMetric) ?? - [], + expression?.metrics?.map(mapMetricThresholdMetricToMetricsExplorerMetric) ?? [], equation: expression.equation, } : { field: expression.metric, aggregation: expression.aggType }, @@ -57,7 +56,7 @@ export const useMetricsExplorerChartData = ( expression.equation, expression.metric, // eslint-disable-next-line react-hooks/exhaustive-deps - JSON.stringify(expression.customMetrics), + JSON.stringify(expression.metrics), filterQuery, groupBy, ] @@ -78,7 +77,9 @@ export const useMetricsExplorerChartData = ( return useMetricsExplorerData(options, derivedIndexPattern, timestamps); }; -const mapMetricThresholdMetricToMetricsExplorerMetric = (metric: MetricExpressionCustomMetric) => { +const mapMetricThresholdMetricToMetricsExplorerMetric = ( + metric: CustomThresholdExpressionMetric +) => { if (metric.aggType === 'count') { return { name: metric.name, diff --git a/x-pack/plugins/observability/public/components/threshold/threshold_rule_expression.tsx b/x-pack/plugins/observability/public/components/threshold/threshold_rule_expression.tsx index 66382ddf1c673..a34f526860772 100644 --- a/x-pack/plugins/observability/public/components/threshold/threshold_rule_expression.tsx +++ b/x-pack/plugins/observability/public/components/threshold/threshold_rule_expression.tsx @@ -144,7 +144,7 @@ export default function Expressions(props: Props) { (newDataView: DataView) => { const ruleCriteria = (ruleParams.criteria ? ruleParams.criteria.slice() : []).map( (criterion) => { - criterion.customMetrics?.forEach((metric) => { + criterion.metrics?.forEach((metric) => { metric.field = undefined; }); return criterion; diff --git a/x-pack/plugins/observability/public/components/threshold/types.ts b/x-pack/plugins/observability/public/components/threshold/types.ts index 59741f40a1356..92d64ab2378bc 100644 --- a/x-pack/plugins/observability/public/components/threshold/types.ts +++ b/x-pack/plugins/observability/public/components/threshold/types.ts @@ -45,10 +45,10 @@ export interface AlertContextMeta { export type MetricExpression = Omit< MetricExpressionParams, - 'metric' | 'timeSize' | 'timeUnit' | 'metrics' | 'equation' | 'customMetrics' + 'metric' | 'timeSize' | 'timeUnit' | 'metrics' | 'equation' > & { metric?: NonCountMetricExpressionParams['metric']; - customMetrics?: CustomMetricExpressionParams['customMetrics']; + metrics?: CustomMetricExpressionParams['metrics']; label?: CustomMetricExpressionParams['label']; equation?: CustomMetricExpressionParams['equation']; timeSize?: MetricExpressionParams['timeSize']; diff --git a/x-pack/plugins/observability/server/lib/rules/threshold/lib/create_custom_metrics_aggregations.ts b/x-pack/plugins/observability/server/lib/rules/threshold/lib/create_custom_metrics_aggregations.ts index 21329d18a1074..a52ad0247475c 100644 --- a/x-pack/plugins/observability/server/lib/rules/threshold/lib/create_custom_metrics_aggregations.ts +++ b/x-pack/plugins/observability/server/lib/rules/threshold/lib/create_custom_metrics_aggregations.ts @@ -7,18 +7,18 @@ import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; import { isEmpty } from 'lodash'; -import { MetricExpressionCustomMetric } from '../../../../../common/threshold_rule/types'; +import { CustomThresholdExpressionMetric } from '../../../../../common/threshold_rule/types'; import { MetricsExplorerCustomMetric } from './metrics_explorer'; const isMetricExpressionCustomMetric = ( - subject: MetricsExplorerCustomMetric | MetricExpressionCustomMetric -): subject is MetricExpressionCustomMetric => { - return (subject as MetricExpressionCustomMetric).aggType != null; + subject: MetricsExplorerCustomMetric | CustomThresholdExpressionMetric +): subject is CustomThresholdExpressionMetric => { + return 'aggType' in subject; }; export const createCustomMetricsAggregations = ( id: string, - customMetrics: Array, + customMetrics: Array, equation?: string ) => { const bucketsPath: { [id: string]: string } = {}; diff --git a/x-pack/plugins/observability/server/lib/rules/threshold/lib/metric_query.ts b/x-pack/plugins/observability/server/lib/rules/threshold/lib/metric_query.ts index 5f46a04522266..3eac288648093 100644 --- a/x-pack/plugins/observability/server/lib/rules/threshold/lib/metric_query.ts +++ b/x-pack/plugins/observability/server/lib/rules/threshold/lib/metric_query.ts @@ -104,7 +104,7 @@ export const getElasticsearchMetricQuery = ( : isCustom(metricParams) ? createCustomMetricsAggregations( 'aggregatedValue', - metricParams.customMetrics, + metricParams.metrics, metricParams.equation ) : { diff --git a/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts b/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts index fa75318530267..09336e03a24ea 100644 --- a/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts +++ b/x-pack/plugins/observability/server/lib/rules/threshold/register_threshold_rule_type.ts @@ -75,7 +75,7 @@ export function thresholdRuleType( ...baseCriterion, metric: schema.string(), aggType: oneOfLiterals(METRIC_EXPLORER_AGGREGATIONS), - customMetrics: schema.never(), + metrics: schema.never(), equation: schema.never(), label: schema.never(), }); @@ -84,7 +84,7 @@ export function thresholdRuleType( ...baseCriterion, aggType: schema.literal('count'), metric: schema.never(), - customMetrics: schema.never(), + metrics: schema.never(), equation: schema.never(), label: schema.never(), }); @@ -93,7 +93,7 @@ export function thresholdRuleType( ...baseCriterion, aggType: schema.literal('custom'), metric: schema.never(), - customMetrics: schema.arrayOf( + metrics: schema.arrayOf( schema.oneOf([ schema.object({ name: schema.string(), diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index c3d6b1732732f..804e6f38ef412 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -27673,9 +27673,6 @@ "xpack.observability.threshold.rule.alertFlyout.customEquationEditor.labelLabel": "Étiquette (facultatif)", "xpack.observability.threshold.rule.alertFlyout.docCountNoDataDisabledHelpText": "[Ce paramètre n’est pas applicable à l’agrégateur du nombre de documents.]", "xpack.observability.threshold.rule.alertFlyout.error.aggregationRequired": "L'agrégation est requise.", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.aggTypeRequired": "L'agrégation est requise", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.fieldRequired": "Le champ est obligatoire", - "xpack.observability.threshold.rule.alertFlyout.error.customMetricsError": "Vous devez définir au moins 1 indicateur personnalisé", "xpack.observability.threshold.rule.alertFlyout.error.equation.invalidCharacters": "Le champ d'équation prend en charge uniquement les caractères suivants : A-Z, +, -, /, *, (, ), ?, !, &, :, |, >, <, =", "xpack.observability.threshold.rule.alertFlyout.error.invalidFilterQuery": "La requête de filtre n'est pas valide.", "xpack.observability.threshold.rule.alertFlyout.error.metricRequired": "L'indicateur est requis.", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 3936b78eb1a01..93352cb7778af 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -27673,9 +27673,6 @@ "xpack.observability.threshold.rule.alertFlyout.customEquationEditor.labelLabel": "ラベル(任意)", "xpack.observability.threshold.rule.alertFlyout.docCountNoDataDisabledHelpText": "[この設定は、ドキュメントカウントアグリゲーターには適用されません。]", "xpack.observability.threshold.rule.alertFlyout.error.aggregationRequired": "集約が必要です。", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.aggTypeRequired": "集約が必要です", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.fieldRequired": "フィールドが必要です", - "xpack.observability.threshold.rule.alertFlyout.error.customMetricsError": "1つ以上のカスタムメトリックを定義する必要があります", "xpack.observability.threshold.rule.alertFlyout.error.equation.invalidCharacters": "等式フィールドでは次の文字のみを使用できます:A-Z、+、-、/、*、(、)、?、!、&、:、|、>、<、=", "xpack.observability.threshold.rule.alertFlyout.error.invalidFilterQuery": "フィルタークエリは無効です。", "xpack.observability.threshold.rule.alertFlyout.error.metricRequired": "メトリックが必要です。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index a75699cf01fca..78e6f5b54c600 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -27671,9 +27671,6 @@ "xpack.observability.threshold.rule.alertFlyout.customEquationEditor.labelLabel": "标签(可选)", "xpack.observability.threshold.rule.alertFlyout.docCountNoDataDisabledHelpText": "[此设置不适用于文档计数聚合器。]", "xpack.observability.threshold.rule.alertFlyout.error.aggregationRequired": "“聚合”必填。", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.aggTypeRequired": "“聚合”必填", - "xpack.observability.threshold.rule.alertFlyout.error.customMetrics.fieldRequired": "“字段”必填", - "xpack.observability.threshold.rule.alertFlyout.error.customMetricsError": "必须至少定义 1 个定制指标", "xpack.observability.threshold.rule.alertFlyout.error.equation.invalidCharacters": "方程字段仅支持以下字符:A-Z、+、-、/、*、(、)、?、!、&、:、|、>、<、=", "xpack.observability.threshold.rule.alertFlyout.error.invalidFilterQuery": "筛选查询无效。", "xpack.observability.threshold.rule.alertFlyout.error.metricRequired": "“指标”必填。", diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_fired.ts index 5c48eb3571ec2..7bb8874dafed9 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_fired.ts @@ -81,7 +81,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.user.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -169,7 +169,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_no_data.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_no_data.ts index 400d5ad55e730..c0138d993e6bd 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_no_data.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_pct_no_data.ts @@ -75,7 +75,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.user.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -163,7 +163,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_us_fired.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_us_fired.ts index 65db9101c04e8..1c35793e04337 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_us_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/avg_us_fired.ts @@ -96,7 +96,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [7500000], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'span.self_time.sum.us', aggType: Aggregators.AVERAGE }, ], }, @@ -189,7 +189,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [7500000], timeSize: 5, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'span.self_time.sum.us', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'span.self_time.sum.us', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/custom_eq_avg_bytes_fired.ts index b05d60ca7f750..794902f19688f 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/custom_eq_avg_bytes_fired.ts @@ -87,7 +87,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.9], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.network.in.bytes', aggType: Aggregators.AVERAGE }, { name: 'B', field: 'system.network.out.bytes', aggType: Aggregators.AVERAGE }, ], @@ -177,7 +177,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.9], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.network.in.bytes', aggType: Aggregators.AVERAGE }, { name: 'B', field: 'system.network.out.bytes', aggType: Aggregators.AVERAGE }, ], diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/documents_count_fired.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/documents_count_fired.ts index 0ccff07f20828..3361f4a04e185 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/documents_count_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/documents_count_fired.ts @@ -81,7 +81,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', filter: '', aggType: Aggregators.COUNT }], + metrics: [{ name: 'A', filter: '', aggType: Aggregators.COUNT }], }, ], alertOnNoData: true, @@ -167,7 +167,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', filter: '', aggType: 'count' }], + metrics: [{ name: 'A', filter: '', aggType: 'count' }], }, ], alertOnNoData: true, diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule/group_by_fired.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule/group_by_fired.ts index 8b2db8b13ca05..9d3e5e2bd17ad 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule/group_by_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule/group_by_fired.ts @@ -94,7 +94,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.2], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.total.norm.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -197,7 +197,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.total.norm.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.total.norm.pct', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test/alerting_api_integration/observability/threshold_rule_data_view.ts b/x-pack/test/alerting_api_integration/observability/threshold_rule_data_view.ts index ba846751ef7b4..f4d26f961c234 100644 --- a/x-pack/test/alerting_api_integration/observability/threshold_rule_data_view.ts +++ b/x-pack/test/alerting_api_integration/observability/threshold_rule_data_view.ts @@ -75,7 +75,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [7500000], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'span.self_time.sum.us', aggType: Aggregators.AVERAGE }, ], }, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_fired.ts index 48256d153b98a..77114463eb89f 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_fired.ts @@ -83,7 +83,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.user.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -169,7 +169,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_no_data.ts b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_no_data.ts index 3d97a7a094339..cbfdf251ba602 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_no_data.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/avg_pct_no_data.ts @@ -76,7 +76,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.user.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -162,7 +162,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.5], timeSize: 5, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.user.pct', aggType: 'avg' }], }, ], alertOnNoData: true, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/custom_eq_avg_bytes_fired.ts index 276ac212dac41..81b57e492f100 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/custom_eq_avg_bytes_fired.ts @@ -88,7 +88,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.9], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.network.in.bytes', aggType: Aggregators.AVERAGE }, { name: 'B', field: 'system.network.out.bytes', aggType: Aggregators.AVERAGE }, ], @@ -176,7 +176,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.9], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.network.in.bytes', aggType: Aggregators.AVERAGE }, { name: 'B', field: 'system.network.out.bytes', aggType: Aggregators.AVERAGE }, ], diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/documents_count_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/documents_count_fired.ts index 0a771d3363791..ad0624a91dfb1 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/documents_count_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/documents_count_fired.ts @@ -82,7 +82,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', filter: '', aggType: Aggregators.COUNT }], + metrics: [{ name: 'A', filter: '', aggType: Aggregators.COUNT }], }, ], alertOnNoData: true, @@ -166,7 +166,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', filter: '', aggType: 'count' }], + metrics: [{ name: 'A', filter: '', aggType: 'count' }], }, ], alertOnNoData: true, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/group_by_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/group_by_fired.ts index b288c4edf28a8..5cadfbc6b3d9d 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/group_by_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/threshold_rule/group_by_fired.ts @@ -92,7 +92,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.2], timeSize: 1, timeUnit: 'm', - customMetrics: [ + metrics: [ { name: 'A', field: 'system.cpu.total.norm.pct', aggType: Aggregators.AVERAGE }, ], }, @@ -193,7 +193,7 @@ export default function ({ getService }: FtrProviderContext) { threshold: [0.2], timeSize: 1, timeUnit: 'm', - customMetrics: [{ name: 'A', field: 'system.cpu.total.norm.pct', aggType: 'avg' }], + metrics: [{ name: 'A', field: 'system.cpu.total.norm.pct', aggType: 'avg' }], }, ], alertOnNoData: true,