-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Alerting] Display Action Group in Alert Details #82645
Changes from 9 commits
bcdda50
10b8c14
9ca4eeb
7b0d9f7
dc4b4da
3d2c08b
3130434
2303e80
de91169
7f4740f
2eab483
10e70e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,11 +104,13 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": true, | ||
"status": "OK", | ||
}, | ||
"instance-2": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": true, | ||
"status": "OK", | ||
|
@@ -184,7 +186,7 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addResolvedInstance('instance-1') | ||
|
@@ -202,6 +204,7 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": false, | ||
"status": "OK", | ||
|
@@ -218,7 +221,7 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const eventsFactory = new EventsFactory(); | ||
const events = eventsFactory | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addResolvedInstance('instance-1') | ||
|
@@ -236,6 +239,7 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": false, | ||
"status": "OK", | ||
|
@@ -253,10 +257,10 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.getEvents(); | ||
|
||
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({ | ||
|
@@ -271,6 +275,79 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": "action group A", | ||
"activeStartDate": "2020-06-18T00:00:00.000Z", | ||
"muted": false, | ||
"status": "Active", | ||
}, | ||
}, | ||
"lastRun": "2020-06-18T00:00:10.000Z", | ||
"status": "Active", | ||
} | ||
`); | ||
}); | ||
|
||
test('alert with currently active instance with no action group in event log', async () => { | ||
const alert = createAlert({}); | ||
const eventsFactory = new EventsFactory(); | ||
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1', undefined) | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1', undefined) | ||
.getEvents(); | ||
|
||
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({ | ||
alert, | ||
events, | ||
dateStart, | ||
dateEnd, | ||
}); | ||
|
||
const { lastRun, status, instances } = summary; | ||
expect({ lastRun, status, instances }).toMatchInlineSnapshot(` | ||
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": "2020-06-18T00:00:00.000Z", | ||
"muted": false, | ||
"status": "Active", | ||
}, | ||
}, | ||
"lastRun": "2020-06-18T00:00:10.000Z", | ||
"status": "Active", | ||
} | ||
`); | ||
}); | ||
|
||
test('alert with currently active instance that switched action groups', async () => { | ||
const alert = createAlert({}); | ||
const eventsFactory = new EventsFactory(); | ||
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1', 'action group B') | ||
.getEvents(); | ||
|
||
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({ | ||
alert, | ||
events, | ||
dateStart, | ||
dateEnd, | ||
}); | ||
|
||
const { lastRun, status, instances } = summary; | ||
expect({ lastRun, status, instances }).toMatchInlineSnapshot(` | ||
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": "action group B", | ||
"activeStartDate": "2020-06-18T00:00:00.000Z", | ||
"muted": false, | ||
"status": "Active", | ||
|
@@ -287,10 +364,10 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const eventsFactory = new EventsFactory(); | ||
const events = eventsFactory | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.getEvents(); | ||
|
||
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({ | ||
|
@@ -305,6 +382,7 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": "action group A", | ||
"activeStartDate": undefined, | ||
"muted": false, | ||
"status": "Active", | ||
|
@@ -322,12 +400,12 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.addNewInstance('instance-2') | ||
.addActiveInstance('instance-2') | ||
.addActiveInstance('instance-2', 'action group B') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.addResolvedInstance('instance-2') | ||
.getEvents(); | ||
|
||
|
@@ -343,11 +421,13 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": "action group A", | ||
"activeStartDate": "2020-06-18T00:00:00.000Z", | ||
"muted": true, | ||
"status": "Active", | ||
}, | ||
"instance-2": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": true, | ||
"status": "OK", | ||
|
@@ -365,19 +445,19 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
const events = eventsFactory | ||
.addExecute() | ||
.addNewInstance('instance-1') | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.addNewInstance('instance-2') | ||
.addActiveInstance('instance-2') | ||
.addActiveInstance('instance-2', 'action group B') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group A') | ||
.addResolvedInstance('instance-2') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group B') | ||
.advanceTime(10000) | ||
.addExecute() | ||
.addActiveInstance('instance-1') | ||
.addActiveInstance('instance-1', 'action group B') | ||
.getEvents(); | ||
|
||
const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({ | ||
|
@@ -392,11 +472,13 @@ describe('alertInstanceSummaryFromEventLog', () => { | |
Object { | ||
"instances": Object { | ||
"instance-1": Object { | ||
"actionGroupId": "action group B", | ||
"activeStartDate": "2020-06-18T00:00:00.000Z", | ||
"muted": false, | ||
"status": "Active", | ||
}, | ||
"instance-2": Object { | ||
"actionGroupId": undefined, | ||
"activeStartDate": undefined, | ||
"muted": false, | ||
"status": "OK", | ||
|
@@ -452,14 +534,17 @@ export class EventsFactory { | |
return this; | ||
} | ||
|
||
addActiveInstance(instanceId: string): EventsFactory { | ||
addActiveInstance(instanceId: string, actionGroupId: string | undefined): EventsFactory { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When might an action not have an action group? 🤔 Or is this for when we resolve? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the |
||
const kibanaAlerting = actionGroupId | ||
? { instance_id: instanceId, action_group_id: actionGroupId } | ||
: { instance_id: instanceId }; | ||
this.events.push({ | ||
'@timestamp': this.date, | ||
event: { | ||
provider: EVENT_LOG_PROVIDER, | ||
action: EVENT_LOG_ACTIONS.activeInstance, | ||
}, | ||
kibana: { alerting: { instance_id: instanceId } }, | ||
kibana: { alerting: kibanaAlerting }, | ||
}); | ||
return this; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me wonder what kind of events we should be generating when an instance "switches" action groups. My first thought was it should probably send a
resolved-instance
with the old action group, and anew-instance
with the new instance group, in between theseactive-instance
events. Which implies sending the action groups onnew-instance
andresolved-instance
as well.But not sure. Perhaps it would be better to leave
new-instance
andresolved-instance
as is, and maybe have a new eventactive-action-group-changed
or such.I think we'll need to think about this a little bit - create a new issue? ie "what events should be logged when an alert switches action groups".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this issue: #82792