diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx index 48371bebb2569..8aeb7e19402fb 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx @@ -200,7 +200,7 @@ export const ExpressionRow = ({ return ( <> - + { method: 'GET', } ); - telemetry.reportPerformanceMetricEvent( + telemetry?.reportPerformanceMetricEvent( 'infra_source_load', performance.now() - start, {}, diff --git a/x-pack/test/functional/services/observability/alerts/rules_page.ts b/x-pack/test/functional/services/observability/alerts/rules_page.ts index 226d257ed918b..76f700f99b999 100644 --- a/x-pack/test/functional/services/observability/alerts/rules_page.ts +++ b/x-pack/test/functional/services/observability/alerts/rules_page.ts @@ -6,6 +6,8 @@ */ import { FtrProviderContext } from '../../../ftr_provider_context'; +const METRIC_THRESHOLD_RULE_TYPE_SELECTOR = 'metrics.alert.threshold-SelectOption'; + export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const find = getService('find'); @@ -30,6 +32,17 @@ export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderCont await find.clickByButtonText('metric-threshold'); }; + const clickOnInfrastructureCategory = async () => { + const categories = await testSubjects.find('ruleTypeModal'); + const category = await categories.findByCssSelector(`.euiFacetButton[title="Infrastructure"]`); + await category.click(); + }; + + const clickOnMetricThresholdRule = async () => { + await testSubjects.existOrFail(METRIC_THRESHOLD_RULE_TYPE_SELECTOR); + await testSubjects.click(METRIC_THRESHOLD_RULE_TYPE_SELECTOR); + }; + return { getManageRulesPageHref, clickCreateRuleButton, @@ -37,5 +50,7 @@ export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderCont clickDisableFromDropDownMenu, clickLogsTab, clickOnRuleInEventLogs, + clickOnInfrastructureCategory, + clickOnMetricThresholdRule, }; } diff --git a/x-pack/test/observability_functional/apps/observability/index.ts b/x-pack/test/observability_functional/apps/observability/index.ts index 67c00ef846a2c..64636e79123d7 100644 --- a/x-pack/test/observability_functional/apps/observability/index.ts +++ b/x-pack/test/observability_functional/apps/observability/index.ts @@ -24,5 +24,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./pages/rules_page')); loadTestFile(require.resolve('./pages/rule_details_page')); loadTestFile(require.resolve('./pages/alert_details_page')); + loadTestFile(require.resolve('./pages/alerts/metric_threshold')); }); } diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/metric_threshold.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/metric_threshold.ts new file mode 100644 index 0000000000000..e474314b72178 --- /dev/null +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/metric_threshold.ts @@ -0,0 +1,38 @@ +/* + * 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 { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default ({ getService }: FtrProviderContext) => { + const esArchiver = getService('esArchiver'); + const testSubjects = getService('testSubjects'); + + describe('Metric threshold rule', function () { + this.tags('includeFirefox'); + + const observability = getService('observability'); + + before(async () => { + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); + await observability.alerts.common.navigateToRulesPage(); + }); + + after(async () => { + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); + }); + + it('shows the metric threshold rule in the observability section', async () => { + await observability.alerts.rulesPage.clickCreateRuleButton(); + await observability.alerts.rulesPage.clickOnInfrastructureCategory(); + await observability.alerts.rulesPage.clickOnMetricThresholdRule(); + }); + + it('shows an expression row in the condition section', async () => { + await testSubjects.existOrFail('metricThresholdExpressionRow'); + }); + }); +};