Skip to content

Commit

Permalink
[Metric threshold] Fix the condition not showing up in the metric thr…
Browse files Browse the repository at this point in the history
…eshold flyout (elastic#192736)

Closes elastic#192439

## Summary

This PR reverts this
[line](https://github.com/elastic/kibana/pull/191948/files#diff-2dd82a791bba3d995e9e6b35d4a973053f166351cc6025a5cd1d24dc789766aeR48)
in a previous [PR](elastic#191948) that
caused an issue in loading the metric threshold flyout on the
observability alerts page.

| Before ❌ | After ✅ |
|---|---|

|![Image](https://github.com/user-attachments/assets/3c0b8812-8cd9-4769-bd20-ab10f559009b)|![Image](https://github.com/user-attachments/assets/9823e691-ce18-4c00-8748-ce5797a19943)|

I also added a small test that fails before this fix.
  • Loading branch information
maryam-saeidi authored Sep 13, 2024
1 parent 9c18dfa commit c304b34
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const ExpressionRow = ({

return (
<>
<EuiFlexGroup gutterSize="xs">
<EuiFlexGroup gutterSize="xs" data-test-subj="metricThresholdExpressionRow">
<EuiFlexItem grow={false}>
<EuiButtonIcon
iconType={isExpanded ? 'arrowDown' : 'arrowRight'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const useSourceFetcher = ({ sourceId }: { sourceId: string }) => {
method: 'GET',
}
);
telemetry.reportPerformanceMetricEvent(
telemetry?.reportPerformanceMetricEvent(
'infra_source_load',
performance.now() - start,
{},
Expand Down
15 changes: 15 additions & 0 deletions x-pack/test/functional/services/observability/alerts/rules_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -30,12 +32,25 @@ 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,
clickRuleStatusDropDownMenu,
clickDisableFromDropDownMenu,
clickLogsTab,
clickOnRuleInEventLogs,
clickOnInfrastructureCategory,
clickOnMetricThresholdRule,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
}
Original file line number Diff line number Diff line change
@@ -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');
});
});
};

0 comments on commit c304b34

Please sign in to comment.