Skip to content

Commit

Permalink
[Metrics UI] Disable recovery action scheduling (#87061)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
Zacqary and kibanamachine authored Jan 6, 2021
1 parent ab944b4 commit 6df7498
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
buildErrorAlertReason,
buildFiredAlertReason,
buildNoDataAlertReason,
buildRecoveredAlertReason,
// buildRecoveredAlertReason,
stateToAlertMessage,
} from '../common/messages';
import { evaluateCondition } from './evaluate_condition';
Expand Down Expand Up @@ -99,9 +99,14 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
.map((result) => buildReasonWithVerboseMetricName(result[item], buildFiredAlertReason))
.join('\n');
} else if (nextState === AlertStates.OK && prevState?.alertState === AlertStates.ALERT) {
reason = results
.map((result) => buildReasonWithVerboseMetricName(result[item], buildRecoveredAlertReason))
.join('\n');
/*
* Custom recovery actions aren't yet available in the alerting framework
* Uncomment the code below once they've been implemented
* Reference: https://github.com/elastic/kibana/issues/87048
*/
// reason = results
// .map((result) => buildReasonWithVerboseMetricName(result[item], buildRecoveredAlertReason))
// .join('\n');
}
if (alertOnNoData) {
if (nextState === AlertStates.NO_DATA) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { createMetricThresholdExecutor, FIRED_ACTIONS } from './metric_threshold_executor';
import { Comparator, AlertStates } from './types';
import * as mocks from './test_mocks';
import { RecoveredActionGroup } from '../../../../../alerts/common';
// import { RecoveredActionGroup } from '../../../../../alerts/common';
import {
alertsMock,
AlertServicesMock,
Expand All @@ -21,7 +21,7 @@ interface AlertTestInstance {
state: any;
}

let persistAlertInstances = false;
let persistAlertInstances = false; // eslint-disable-line prefer-const

const mockOptions = {
alertId: '',
Expand Down Expand Up @@ -366,6 +366,13 @@ describe('The metric threshold alert type', () => {
});
});

/*
* Custom recovery actions aren't yet available in the alerting framework
* Uncomment the code below once they've been implemented
* Reference: https://github.com/elastic/kibana/issues/87048
*/

/*
describe('querying a metric that later recovers', () => {
const instanceID = '*';
const execute = (threshold: number[]) =>
Expand Down Expand Up @@ -410,6 +417,7 @@ describe('The metric threshold alert type', () => {
expect(getState(instanceID).alertState).toBe(AlertStates.OK);
});
});
*/

describe('querying a metric with a percentage metric', () => {
const instanceID = '*';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
buildErrorAlertReason,
buildFiredAlertReason,
buildNoDataAlertReason,
buildRecoveredAlertReason,
// buildRecoveredAlertReason,
stateToAlertMessage,
} from '../common/messages';
import { createFormatter } from '../../../../common/formatters';
Expand Down Expand Up @@ -77,9 +77,14 @@ export const createMetricThresholdExecutor = (
.map((result) => buildFiredAlertReason(formatAlertResult(result[group])))
.join('\n');
} else if (nextState === AlertStates.OK && prevState?.alertState === AlertStates.ALERT) {
reason = alertResults
.map((result) => buildRecoveredAlertReason(formatAlertResult(result[group])))
.join('\n');
/*
* Custom recovery actions aren't yet available in the alerting framework
* Uncomment the code below once they've been implemented
* Reference: https://github.com/elastic/kibana/issues/87048
*/
// reason = alertResults
// .map((result) => buildRecoveredAlertReason(formatAlertResult(result[group])))
// .join('\n');
}
if (alertOnNoData) {
if (nextState === AlertStates.NO_DATA) {
Expand Down

0 comments on commit 6df7498

Please sign in to comment.