Skip to content

Commit

Permalink
[8.x] [Metric threshold] Fix the condition not showing up in the metr…
Browse files Browse the repository at this point in the history
…ic threshold flyout (#192736) (#192825)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Metric threshold] Fix the condition not showing up in the metric
threshold flyout
(#192736)](#192736)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-13T09:10:15Z","message":"[Metric
threshold] Fix the condition not showing up in the metric threshold
flyout (#192736)\n\nCloses #192439\r\n\r\n## Summary\r\n\r\nThis PR
reverts
this\r\n[line](https://github.com/elastic/kibana/pull/191948/files#diff-2dd82a791bba3d995e9e6b35d4a973053f166351cc6025a5cd1d24dc789766aeR48)\r\nin
a previous [PR](#191948)
that\r\ncaused an issue in loading the metric threshold flyout on
the\r\nobservability alerts page.\r\n\r\n| Before ❌ | After ✅
|\r\n|---|---|\r\n\r\n|![Image](https://github.com/user-attachments/assets/3c0b8812-8cd9-4769-bd20-ab10f559009b)|![Image](https://github.com/user-attachments/assets/9823e691-ce18-4c00-8748-ce5797a19943)|\r\n\r\nI
also added a small test that fails before this
fix.","sha":"c304b34e0edd90dedcb67dff10da6472d4a823c0","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:prev-major","ci:project-deploy-observability"],"title":"[Metric
threshold] Fix the condition not showing up in the metric threshold
flyout","number":192736,"url":"https://github.com/elastic/kibana/pull/192736","mergeCommit":{"message":"[Metric
threshold] Fix the condition not showing up in the metric threshold
flyout (#192736)\n\nCloses #192439\r\n\r\n## Summary\r\n\r\nThis PR
reverts
this\r\n[line](https://github.com/elastic/kibana/pull/191948/files#diff-2dd82a791bba3d995e9e6b35d4a973053f166351cc6025a5cd1d24dc789766aeR48)\r\nin
a previous [PR](#191948)
that\r\ncaused an issue in loading the metric threshold flyout on
the\r\nobservability alerts page.\r\n\r\n| Before ❌ | After ✅
|\r\n|---|---|\r\n\r\n|![Image](https://github.com/user-attachments/assets/3c0b8812-8cd9-4769-bd20-ab10f559009b)|![Image](https://github.com/user-attachments/assets/9823e691-ce18-4c00-8748-ce5797a19943)|\r\n\r\nI
also added a small test that fails before this
fix.","sha":"c304b34e0edd90dedcb67dff10da6472d4a823c0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192736","number":192736,"mergeCommit":{"message":"[Metric
threshold] Fix the condition not showing up in the metric threshold
flyout (#192736)\n\nCloses #192439\r\n\r\n## Summary\r\n\r\nThis PR
reverts
this\r\n[line](https://github.com/elastic/kibana/pull/191948/files#diff-2dd82a791bba3d995e9e6b35d4a973053f166351cc6025a5cd1d24dc789766aeR48)\r\nin
a previous [PR](#191948)
that\r\ncaused an issue in loading the metric threshold flyout on
the\r\nobservability alerts page.\r\n\r\n| Before ❌ | After ✅
|\r\n|---|---|\r\n\r\n|![Image](https://github.com/user-attachments/assets/3c0b8812-8cd9-4769-bd20-ab10f559009b)|![Image](https://github.com/user-attachments/assets/9823e691-ce18-4c00-8748-ce5797a19943)|\r\n\r\nI
also added a small test that fails before this
fix.","sha":"c304b34e0edd90dedcb67dff10da6472d4a823c0"}}]}] BACKPORT-->

Co-authored-by: Maryam Saeidi <[email protected]>
  • Loading branch information
kibanamachine and maryam-saeidi authored Sep 13, 2024
1 parent 77b7a0e commit 21b86ae
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 21b86ae

Please sign in to comment.