GDATASoftwareAG / Graylog-Plugin-AlertManager-Callback

A plugin for Graylog which provides the possibility to send alerts to the Prometheus AlertManager API.
MIT License
24 stars 5 forks source link

Add variables in custom annotations and labels #7

Closed jidckii closed 5 years ago

jidckii commented 5 years ago

Add for custom annotations and labels variables, as in this example email: http://docs.graylog.org/en/2.5/pages/streams/alerts.html#email-alert-notification Now this don't work. https://i.imgur.com/9BslOJn.png https://i.imgur.com/IjzCELz.png

StefanHufschmidt commented 5 years ago

I've added some code for the first draft inside a feature branch. It works as expected. You can use variables inside custom annotations and labels like this: "mystreamtitle=${stream.title};myresultdesc=${check_result.resultDescription};mytriggeredat=${check_result.triggeredAt};mystreamid=${stream.id};mystreamdescription=${stream.description};myalertconditiontitle=${alertCondition.title};myalertconditiondesc=${alertCondition.description};mytriggeredcondition=${check_result.triggeredCondition};". I'll add some more tests tomorrow to ensure that using the template engine will not cause side effects.

edgarasg commented 5 years ago

Can we also get ${message.message} on which the alert was triggered as variable?

StefanHufschmidt commented 5 years ago

Can we also get ${message.message} on which the alert was triggered as variable?

Well, this should be possible as in the E-Mail-Callback. When you use this as value: ${foreach backlog message}${message} ${end} it should append all messages matching your condition to a maximum you have defined.

So when you only have one matching message there should only be one written to your annotation.

edgarasg commented 5 years ago

Thanks!

jidckii commented 5 years ago

@StefanHufschmidt
Hey. Is this functionality not yet added to any release?

StefanHufschmidt commented 5 years ago

@jidckii sorry for the delay, I think @jlnshr will take a look at it now and it should be released within the next hours.

StefanHufschmidt commented 5 years ago

Merged into master, released with version 1.2