cmd/bosun: (wip) link previous incidents and next incident #2323
Conversation
TODO:
|
example for the template func:
|
Fancier table with col/rowspan (note to self: if making into example check for nil on incident End time just in case):
|
slog.Infoln("Running population of previous incidents. This can take several minutes.") | ||
|
||
// Hacky Work better? | ||
ids, err := d.getAllIncidentIdsByKeys() |
captncraig
Oct 1, 2018
Contributor
Possibly collect Alert Keys up front, and run inner loop once per alert key, not once per incident.
Possibly collect Alert Keys up front, and run inner loop once per alert key, not once per incident.
return err | ||
} | ||
previousIds := []int64{} | ||
previousIds, err = d.State().GetAllIncidentIdsByAlertKey(incident.AlertKey) |
captncraig
Oct 1, 2018
Contributor
At least cache these results by alert key.
At least cache these results by alert key.
} | ||
for _, id := range previousIds { | ||
if incident.Id > id { | ||
incident.PreviousIds = append(incident.PreviousIds, id) |
captncraig
Oct 1, 2018
Contributor
Wait, we're storing all previous alert keys on every alert? Gross. Why?
Wait, we're storing all previous alert keys on every alert? Gross. Why?
kylebrandt
Oct 1, 2018
Author
Member
@captncraig To make it easier to either:
- Display more than just the previous incident in a view
- Make it easier to iterate over all previous incidents in templates without having to follow a linked list.
@captncraig To make it easier to either:
- Display more than just the previous incident in a view
- Make it easier to iterate over all previous incidents in templates without having to follow a linked list.
kylebrandt
Oct 1, 2018
Author
Member
Also to clarify not the previous alert keys, just an array of incident id numbers (int64)
Also to clarify not the previous alert keys, just an array of incident id numbers (int64)
kylebrandt
Oct 1, 2018
Author
Member
Another Also :P alert keys are the alert name plus the tagset (not all alerts under the name, unless the tagset is {}
or of len 1. So the list generally should not be crazy long.
Another Also :P alert keys are the alert name plus the tagset (not all alerts under the name, unless the tagset is {}
or of len 1. So the list generally should not be crazy long.
captncraig
Oct 2, 2018
Contributor
I guess I'm just uncomfortable anytime I see potentially large, and also redundant, and also repetitive collections or lists.
I guess though I'd rather a template could show them all without having to recursively traverse the chain, which was gonna be the alternative I suggested. So ok.
I guess I'm just uncomfortable anytime I see potentially large, and also redundant, and also repetitive collections or lists.
I guess though I'd rather a template could show them all without having to recursively traverse the chain, which was gonna be the alternative I suggested. So ok.
You should back up your redis db before this Migration operation. This will update all incidents in redis/ledis, bosun will not start until this one-time operation is complete. ~100k incidents took two minutes with redis on a development workstation. Add GetIncidentState template function, as well as PreviousIds field to templates.
requires a migration as all of the IncidentState objects are updated.
This makes it so when viewing incidents you can quickly navigate to previous incidents
or the next incident if there is a new one for the same alert key.