Need to execute the script on alert trigger

657 views
Skip to first unread message

P Chanti

unread,
Apr 4, 2022, 12:11:33 PM4/4/22
to Prometheus Users
Hi,

Can you please help me with how to execute the script on alert triggers?

Regards,
Chanti


Brian Candler

unread,
Apr 4, 2022, 1:38:53 PM4/4/22
to Prometheus Users
https://prometheus.io/docs/alerting/latest/configuration/#webhook_config

You need to write your own webhook receiver, which will be a simple webserver, in a language of your choice.

P Chanti

unread,
Apr 18, 2022, 2:46:02 AM4/18/22
to Prometheus Users
Hi,

Can you please more details on this, I didn't understand the webhook_config link.

Brian Candler

unread,
Apr 18, 2022, 3:19:34 AM4/18/22
to Prometheus Users
There's not really much to understand:

1. Alertmanager makes a HTTP connection to your webhook. The only mandatory configuration is "url", which is the URL where to send the webhook request to.
2. The documentation then shows the format of the webhook payload (body) which your webhook server will receive.

Therefore, all you need to do is to write a small web server in any language of your choice, which receives the webhook request, and acts on it however you want.

If you google for "alertmanager webhook run script" then you'll get the following as the first three hits:

which in turn will link you to some ready-made solutions:
Reply all
Reply to author
Forward
0 new messages