-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AO] Add threshold information to the metric threshold alert details …
…page (#155493) Closes #153740, closes #153833, closes #155593 This PR adds threshold information and rule name to the metric threshold alert details page. ![image](https://user-images.githubusercontent.com/12370520/233968325-8a66166b-2534-4b9b-9054-9085270db5f6.png) ## 🧪 How to test - Add xpack.observability.unsafe.alertDetails.metrics.enabled: true to the Kibana config - Create a metric threshold rule with multiple conditions that generates an alert - Go to the alert details page and check threshold information - Click on the rule link; it should send you to the rule page
- Loading branch information
1 parent
0ecb2cb
commit dfea483
Showing
8 changed files
with
225 additions
and
49 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/infra/common/alerting/metrics/metric_value_formatter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { metricValueFormatter } from './metric_value_formatter'; | ||
|
||
describe('metricValueFormatter', () => { | ||
const testData = [ | ||
{ value: null, metric: undefined, result: '[NO DATA]' }, | ||
{ value: null, metric: 'system.cpu.user.pct', result: '[NO DATA]' }, | ||
{ value: 50, metric: undefined, result: '50' }, | ||
{ value: 0.7, metric: 'system.cpu.user.pct', result: '70%' }, | ||
{ value: 0.7012345, metric: 'system.cpu.user.pct', result: '70.1%' }, | ||
{ value: 208, metric: 'system.cpu.user.ticks', result: '208' }, | ||
{ value: 0.8, metric: 'system.cpu.user.ticks', result: '0.8' }, | ||
]; | ||
|
||
it.each(testData)( | ||
'metricValueFormatter($value, $metric) = $result', | ||
({ value, metric, result }) => { | ||
expect(metricValueFormatter(value, metric)).toBe(result); | ||
} | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/infra/common/alerting/metrics/metric_value_formatter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { createFormatter } from '../../formatters'; | ||
|
||
export const metricValueFormatter = (value: number | null, metric: string = '') => { | ||
const noDataValue = i18n.translate('xpack.infra.metrics.alerting.noDataFormattedValue', { | ||
defaultMessage: '[NO DATA]', | ||
}); | ||
|
||
const formatter = metric.endsWith('.pct') | ||
? createFormatter('percent') | ||
: createFormatter('highPrecision'); | ||
|
||
return value == null ? noDataValue : formatter(value); | ||
}; |
1 change: 1 addition & 0 deletions
1
...lerting/metric_threshold/components/__snapshots__/alert_details_app_section.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.