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

Hande User responder type #5

Closed MattMofDoom closed 3 years ago

MattMofDoom commented 3 years ago

Hi @nblumhardt,

Per my comment on #4, testing went well overall, but I found that there was a case where the responder field wasn't accepted by the OpsGenie API, if the responder type was a user.

The OpsGenie alert API uses the "name" field for Team, Type, and Schedule. For User, it uses the "username" field. https://docs.opsgenie.com/docs/alert-api

To handle that I've added the Username field to Responder, and set the JsonIgnore attribute with Condition=JsonIgnoreCondition.WhenWritingNull for both Username and Name.

I've then set ComputeResponders and the OnAttached responder evaluation to assign according to username or name.

My thinking is that this should handle the different cases identified, and pass the correct result to OpsGenie.

It wouldn't be a stretch for this to also handle an "id" guid if it was detected, but I preferred to base the Responder field against names rather than ids.

Cheers,

Matt

nblumhardt commented 3 years ago

Looks good to me 👍

Things are still moving nice and quickly as we shape up this app - let's send this one through the works!

MattMofDoom commented 3 years ago

@nblumhardt Tested against OpsGenie and good news. I tested against a User and an Escalation, and each was accepted by OpsGenie and visible in the logs 😊

I had one further thought on this - allowing the Responder property to be a string, array, or comma-separated list would mean that multiple responders could be matched against the property mapping. I'm not sure why I didn't implement that in the first place.