datalust / seq-app-opsgenie

Create Opsgenie alerts in response to events or notifications in Seq
Apache License 2.0
3 stars 2 forks source link

Dynamic Priority and Responder, $EventUri property for Handlebars template #3

Closed MattMofDoom closed 3 years ago

MattMofDoom commented 3 years ago

Hi @nblumhardt ,

This pull request is a follow-on to #1 and with reference to https://github.com/datalust/seq-tickets/issues/1221

The enhancement adds an optional ability to specify event property names that can map to the Responder and Priority field.

The value of this extension is that it can better tie structured properties to alerts. As an example, I could have a column from events ingested via https://www.nuget.org/packages/Seq.Input.MSSql/ tied directly to Priority, or at its simplest, have events with @Level = Critical raise a P1, @Level = Error raise a P2, @Level = Information raise a P3.

Responder is probably more forward looking in terms of utility. If my suggestion for dashboard alerts were implemented, it would fit neatly with this; however it also provides opportunity for unforeseen usages - I might decide to implement it in a Seq app and then be able to have it automatically pass through to OpsGenie.

I also extend the Handlebars Template to natively provide $EventUri - a link to the event - for convenience.

Finally, I have made the matching of property keys case-insensitive, with logic to exit the required loop as early as possible, and switched string comparisons to OrdinalIgnoreCase.

Cheers,

Matt

nblumhardt commented 3 years ago

Hi @MattMofDoom - looks great! The "mapping" syntax/convention is really nice :+1:

I have a few stylistic comments but it will be an order of magnitude quicker for me to check out a branch and let Rider work its reformatting magic than it will be to write it up here :-), so I'll merge as it is and tinker with it on dev 👍

MattMofDoom commented 3 years ago

@nblumhardt Awesome, thanks :-) I don't have licensing for any Jetbrains goodies so sounds great.