Skip to content

Commit 0b5c55c

Browse files
author
Tyler Smalley
committed
Revert "[Alerting] renames Resolved action group to Recovered (elastic#84123)"
This reverts commit 7dcaff5.
1 parent 920e4fa commit 0b5c55c

File tree

19 files changed

+90
-147
lines changed

19 files changed

+90
-147
lines changed

x-pack/plugins/alerts/common/builtin_action_groups.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import { i18n } from '@kbn/i18n';
77
import { ActionGroup } from './alert_type';
88

9-
export const RecoveredActionGroup: ActionGroup = {
10-
id: 'recovered',
11-
name: i18n.translate('xpack.alerts.builtinActionGroups.recovered', {
12-
defaultMessage: 'Recovered',
9+
export const ResolvedActionGroup: ActionGroup = {
10+
id: 'resolved',
11+
name: i18n.translate('xpack.alerts.builtinActionGroups.resolved', {
12+
defaultMessage: 'Resolved',
1313
}),
1414
};
1515

1616
export function getBuiltinActionGroups(): ActionGroup[] {
17-
return [RecoveredActionGroup];
17+
return [ResolvedActionGroup];
1818
}

x-pack/plugins/alerts/server/alert_type_registry.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ describe('register()', () => {
105105
name: 'Default',
106106
},
107107
{
108-
id: 'recovered',
109-
name: 'Recovered',
108+
id: 'resolved',
109+
name: 'Resolved',
110110
},
111111
],
112112
defaultActionGroupId: 'default',
@@ -117,7 +117,7 @@ describe('register()', () => {
117117

118118
expect(() => registry.register(alertType)).toThrowError(
119119
new Error(
120-
`Alert type [id="${alertType.id}"] cannot be registered. Action groups [recovered] are reserved by the framework.`
120+
`Alert type [id="${alertType.id}"] cannot be registered. Action groups [resolved] are reserved by the framework.`
121121
)
122122
);
123123
});
@@ -229,8 +229,8 @@ describe('get()', () => {
229229
"name": "Default",
230230
},
231231
Object {
232-
"id": "recovered",
233-
"name": "Recovered",
232+
"id": "resolved",
233+
"name": "Resolved",
234234
},
235235
],
236236
"actionVariables": Object {
@@ -287,8 +287,8 @@ describe('list()', () => {
287287
"name": "Test Action Group",
288288
},
289289
Object {
290-
"id": "recovered",
291-
"name": "Recovered",
290+
"id": "resolved",
291+
"name": "Resolved",
292292
},
293293
],
294294
"actionVariables": Object {

x-pack/plugins/alerts/server/alerts_client/tests/get_alert_instance_summary.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('getAlertInstanceSummary()', () => {
122122
.addActiveInstance('instance-previously-active', 'action group B')
123123
.advanceTime(10000)
124124
.addExecute()
125-
.addRecoveredInstance('instance-previously-active')
125+
.addResolvedInstance('instance-previously-active')
126126
.addActiveInstance('instance-currently-active', 'action group A')
127127
.getEvents();
128128
const eventsResult = {

x-pack/plugins/alerts/server/lib/alert_instance_summary_from_event_log.test.ts

+7-55
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { SanitizedAlert, AlertInstanceSummary } from '../types';
88
import { IValidatedEvent } from '../../../event_log/server';
9-
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER, LEGACY_EVENT_LOG_ACTIONS } from '../plugin';
9+
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER } from '../plugin';
1010
import { alertInstanceSummaryFromEventLog } from './alert_instance_summary_from_event_log';
1111

1212
const ONE_HOUR_IN_MILLIS = 60 * 60 * 1000;
@@ -189,43 +189,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
189189
.addActiveInstance('instance-1', 'action group A')
190190
.advanceTime(10000)
191191
.addExecute()
192-
.addRecoveredInstance('instance-1')
193-
.getEvents();
194-
195-
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
196-
alert,
197-
events,
198-
dateStart,
199-
dateEnd,
200-
});
201-
202-
const { lastRun, status, instances } = summary;
203-
expect({ lastRun, status, instances }).toMatchInlineSnapshot(`
204-
Object {
205-
"instances": Object {
206-
"instance-1": Object {
207-
"actionGroupId": undefined,
208-
"activeStartDate": undefined,
209-
"muted": false,
210-
"status": "OK",
211-
},
212-
},
213-
"lastRun": "2020-06-18T00:00:10.000Z",
214-
"status": "OK",
215-
}
216-
`);
217-
});
218-
219-
test('legacy alert with currently inactive instance', async () => {
220-
const alert = createAlert({});
221-
const eventsFactory = new EventsFactory();
222-
const events = eventsFactory
223-
.addExecute()
224-
.addNewInstance('instance-1')
225-
.addActiveInstance('instance-1', 'action group A')
226-
.advanceTime(10000)
227-
.addExecute()
228-
.addLegacyResolvedInstance('instance-1')
192+
.addResolvedInstance('instance-1')
229193
.getEvents();
230194

231195
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
@@ -260,7 +224,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
260224
.addActiveInstance('instance-1', 'action group A')
261225
.advanceTime(10000)
262226
.addExecute()
263-
.addRecoveredInstance('instance-1')
227+
.addResolvedInstance('instance-1')
264228
.getEvents();
265229

266230
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
@@ -442,7 +406,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
442406
.advanceTime(10000)
443407
.addExecute()
444408
.addActiveInstance('instance-1', 'action group A')
445-
.addRecoveredInstance('instance-2')
409+
.addResolvedInstance('instance-2')
446410
.getEvents();
447411

448412
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
@@ -487,7 +451,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
487451
.advanceTime(10000)
488452
.addExecute()
489453
.addActiveInstance('instance-1', 'action group A')
490-
.addRecoveredInstance('instance-2')
454+
.addResolvedInstance('instance-2')
491455
.advanceTime(10000)
492456
.addExecute()
493457
.addActiveInstance('instance-1', 'action group B')
@@ -597,24 +561,12 @@ export class EventsFactory {
597561
return this;
598562
}
599563

600-
addRecoveredInstance(instanceId: string): EventsFactory {
601-
this.events.push({
602-
'@timestamp': this.date,
603-
event: {
604-
provider: EVENT_LOG_PROVIDER,
605-
action: EVENT_LOG_ACTIONS.recoveredInstance,
606-
},
607-
kibana: { alerting: { instance_id: instanceId } },
608-
});
609-
return this;
610-
}
611-
612-
addLegacyResolvedInstance(instanceId: string): EventsFactory {
564+
addResolvedInstance(instanceId: string): EventsFactory {
613565
this.events.push({
614566
'@timestamp': this.date,
615567
event: {
616568
provider: EVENT_LOG_PROVIDER,
617-
action: LEGACY_EVENT_LOG_ACTIONS.resolvedInstance,
569+
action: EVENT_LOG_ACTIONS.resolvedInstance,
618570
},
619571
kibana: { alerting: { instance_id: instanceId } },
620572
});

x-pack/plugins/alerts/server/lib/alert_instance_summary_from_event_log.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { SanitizedAlert, AlertInstanceSummary, AlertInstanceStatus } from '../types';
88
import { IEvent } from '../../../event_log/server';
9-
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER, LEGACY_EVENT_LOG_ACTIONS } from '../plugin';
9+
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER } from '../plugin';
1010

1111
export interface AlertInstanceSummaryFromEventLogParams {
1212
alert: SanitizedAlert;
@@ -80,8 +80,7 @@ export function alertInstanceSummaryFromEventLog(
8080
status.status = 'Active';
8181
status.actionGroupId = event?.kibana?.alerting?.action_group_id;
8282
break;
83-
case LEGACY_EVENT_LOG_ACTIONS.resolvedInstance:
84-
case EVENT_LOG_ACTIONS.recoveredInstance:
83+
case EVENT_LOG_ACTIONS.resolvedInstance:
8584
status.status = 'OK';
8685
status.activeStartDate = undefined;
8786
status.actionGroupId = undefined;

x-pack/plugins/alerts/server/plugin.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ export const EVENT_LOG_ACTIONS = {
8282
execute: 'execute',
8383
executeAction: 'execute-action',
8484
newInstance: 'new-instance',
85-
recoveredInstance: 'recovered-instance',
86-
activeInstance: 'active-instance',
87-
};
88-
export const LEGACY_EVENT_LOG_ACTIONS = {
8985
resolvedInstance: 'resolved-instance',
86+
activeInstance: 'active-instance',
9087
};
9188

9289
export interface PluginSetupContract {

x-pack/plugins/alerts/server/task_runner/task_runner.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import { alertsMock, alertsClientMock } from '../mocks';
2626
import { eventLoggerMock } from '../../../event_log/server/event_logger.mock';
2727
import { IEventLogger } from '../../../event_log/server';
2828
import { SavedObjectsErrorHelpers } from '../../../../../src/core/server';
29-
import { Alert, RecoveredActionGroup } from '../../common';
29+
import { Alert, ResolvedActionGroup } from '../../common';
3030
import { omit } from 'lodash';
3131
const alertType = {
3232
id: 'test',
3333
name: 'My test alert',
34-
actionGroups: [{ id: 'default', name: 'Default' }, RecoveredActionGroup],
34+
actionGroups: [{ id: 'default', name: 'Default' }, ResolvedActionGroup],
3535
defaultActionGroupId: 'default',
3636
executor: jest.fn(),
3737
producer: 'alerts',
@@ -114,7 +114,7 @@ describe('Task Runner', () => {
114114
},
115115
},
116116
{
117-
group: RecoveredActionGroup.id,
117+
group: ResolvedActionGroup.id,
118118
id: '2',
119119
actionTypeId: 'action',
120120
params: {
@@ -517,7 +517,7 @@ describe('Task Runner', () => {
517517
`);
518518
});
519519

520-
test('fire recovered actions for execution for the alertInstances which is in the recovered state', async () => {
520+
test('fire resolved actions for execution for the alertInstances which is in the resolved state', async () => {
521521
taskRunnerFactoryInitializerParams.actionsPlugin.isActionTypeEnabled.mockReturnValue(true);
522522
taskRunnerFactoryInitializerParams.actionsPlugin.isActionExecutable.mockReturnValue(true);
523523

@@ -650,7 +650,7 @@ describe('Task Runner', () => {
650650
Array [
651651
Object {
652652
"event": Object {
653-
"action": "recovered-instance",
653+
"action": "resolved-instance",
654654
},
655655
"kibana": Object {
656656
"alerting": Object {
@@ -666,7 +666,7 @@ describe('Task Runner', () => {
666666
},
667667
],
668668
},
669-
"message": "test:1: 'alert-name' instance '2' has recovered",
669+
"message": "test:1: 'alert-name' resolved instance: '2'",
670670
},
671671
],
672672
Array [

x-pack/plugins/alerts/server/task_runner/task_runner.ts

+15-17
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { IEvent, IEventLogger, SAVED_OBJECT_REL_PRIMARY } from '../../../event_l
3939
import { isAlertSavedObjectNotFoundError } from '../lib/is_alert_not_found_error';
4040
import { AlertsClient } from '../alerts_client';
4141
import { partiallyUpdateAlert } from '../saved_objects';
42-
import { RecoveredActionGroup } from '../../common';
42+
import { ResolvedActionGroup } from '../../common';
4343

4444
const FALLBACK_RETRY_INTERVAL = '5m';
4545

@@ -219,7 +219,7 @@ export class TaskRunner {
219219
alertInstance.hasScheduledActions()
220220
);
221221

222-
generateNewAndRecoveredInstanceEvents({
222+
generateNewAndResolvedInstanceEvents({
223223
eventLogger,
224224
originalAlertInstances,
225225
currentAlertInstances: instancesWithScheduledActions,
@@ -229,7 +229,7 @@ export class TaskRunner {
229229
});
230230

231231
if (!muteAll) {
232-
scheduleActionsForRecoveredInstances(
232+
scheduleActionsForResolvedInstances(
233233
alertInstances,
234234
executionHandler,
235235
originalAlertInstances,
@@ -436,7 +436,7 @@ export class TaskRunner {
436436
}
437437
}
438438

439-
interface GenerateNewAndRecoveredInstanceEventsParams {
439+
interface GenerateNewAndResolvedInstanceEventsParams {
440440
eventLogger: IEventLogger;
441441
originalAlertInstances: Dictionary<AlertInstance>;
442442
currentAlertInstances: Dictionary<AlertInstance>;
@@ -445,20 +445,18 @@ interface GenerateNewAndRecoveredInstanceEventsParams {
445445
namespace: string | undefined;
446446
}
447447

448-
function generateNewAndRecoveredInstanceEvents(
449-
params: GenerateNewAndRecoveredInstanceEventsParams
450-
) {
448+
function generateNewAndResolvedInstanceEvents(params: GenerateNewAndResolvedInstanceEventsParams) {
451449
const { eventLogger, alertId, namespace, currentAlertInstances, originalAlertInstances } = params;
452450
const originalAlertInstanceIds = Object.keys(originalAlertInstances);
453451
const currentAlertInstanceIds = Object.keys(currentAlertInstances);
454452

455453
const newIds = without(currentAlertInstanceIds, ...originalAlertInstanceIds);
456-
const recoveredIds = without(originalAlertInstanceIds, ...currentAlertInstanceIds);
454+
const resolvedIds = without(originalAlertInstanceIds, ...currentAlertInstanceIds);
457455

458-
for (const id of recoveredIds) {
456+
for (const id of resolvedIds) {
459457
const actionGroup = originalAlertInstances[id].getLastScheduledActions()?.group;
460-
const message = `${params.alertLabel} instance '${id}' has recovered`;
461-
logInstanceEvent(id, EVENT_LOG_ACTIONS.recoveredInstance, message, actionGroup);
458+
const message = `${params.alertLabel} resolved instance: '${id}'`;
459+
logInstanceEvent(id, EVENT_LOG_ACTIONS.resolvedInstance, message, actionGroup);
462460
}
463461

464462
for (const id of newIds) {
@@ -498,7 +496,7 @@ function generateNewAndRecoveredInstanceEvents(
498496
}
499497
}
500498

501-
function scheduleActionsForRecoveredInstances(
499+
function scheduleActionsForResolvedInstances(
502500
alertInstancesMap: Record<string, AlertInstance>,
503501
executionHandler: ReturnType<typeof createExecutionHandler>,
504502
originalAlertInstances: Record<string, AlertInstance>,
@@ -507,22 +505,22 @@ function scheduleActionsForRecoveredInstances(
507505
) {
508506
const currentAlertInstanceIds = Object.keys(currentAlertInstances);
509507
const originalAlertInstanceIds = Object.keys(originalAlertInstances);
510-
const recoveredIds = without(
508+
const resolvedIds = without(
511509
originalAlertInstanceIds,
512510
...currentAlertInstanceIds,
513511
...mutedInstanceIds
514512
);
515-
for (const id of recoveredIds) {
513+
for (const id of resolvedIds) {
516514
const instance = alertInstancesMap[id];
517-
instance.updateLastScheduledActions(RecoveredActionGroup.id);
515+
instance.updateLastScheduledActions(ResolvedActionGroup.id);
518516
instance.unscheduleActions();
519517
executionHandler({
520-
actionGroup: RecoveredActionGroup.id,
518+
actionGroup: ResolvedActionGroup.id,
521519
context: {},
522520
state: {},
523521
alertInstanceId: id,
524522
});
525-
instance.scheduleActions(RecoveredActionGroup.id);
523+
instance.scheduleActions(ResolvedActionGroup.id);
526524
}
527525
}
528526

x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import moment from 'moment';
99
import { getCustomMetricLabel } from '../../../../common/formatters/get_custom_metric_label';
1010
import { toMetricOpt } from '../../../../common/snapshot_metric_i18n';
1111
import { AlertStates, InventoryMetricConditions } from './types';
12-
import { RecoveredActionGroup } from '../../../../../alerts/common';
12+
import { ResolvedActionGroup } from '../../../../../alerts/common';
1313
import { AlertExecutorOptions } from '../../../../../alerts/server';
1414
import { InventoryItemType, SnapshotMetricType } from '../../../../common/inventory_models/types';
1515
import { InfraBackendLibs } from '../../infra_types';
@@ -103,7 +103,7 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
103103
}
104104
if (reason) {
105105
const actionGroupId =
106-
nextState === AlertStates.OK ? RecoveredActionGroup.id : FIRED_ACTIONS.id;
106+
nextState === AlertStates.OK ? ResolvedActionGroup.id : FIRED_ACTIONS.id;
107107
alertInstance.scheduleActions(actionGroupId, {
108108
group: item,
109109
alertState: stateToAlertMessage[nextState],

0 commit comments

Comments
 (0)