Server CentOS7 and intalled alertmanager in OpenShift 3.11.
When some alert is triggered, i want run shell-script.
Now, yml-file in Config Map alertmanager contains block receivers:
and he work fine.
In end point i want run command "curl -X POST "https://some-site/?var=text1""
Please, help.
Linux 3.10.0-862.14.4.el7.x86_64 x86_64
alertmanager, version 0.15.1 (branch: HEAD, revision: 8397de1830f154535a31150f9262da0072d8725d)
build user: root@prometheus-alertmanager-binary-3-build
build date: 20180720-09:32:24
go version: go1.10.3
prometheus, version 2.3.2 (branch: HEAD, revision: 71af5e29e815795e9dd14742ee7725682fa14b7b)
build user: root@prometheus-binary-6-build
build date: 20180720-09:19:12
go version: go1.10.3
You should have a look at https://github.com/imgix/prometheus-am-executor or https://github.com/adnanh/webhook
Big thanks. I'm gotting this - https://github.com/adnanh/webhook. This is solution IMHO very simple.
My steps:
curl -I -X POST "https://
FROM centos:7
COPY webhook /usr/bin/
COPY hooks.json /var/webhook/
COPY sendmessage.sh /usr/bin/
RUN chmod +x /usr/bin/sendmessage.sh
CMD ["/usr/bin/webhook", "-verbose", "-hooks=/var/webhook/hooks.json", "-hotreload"]
Create some folder and copy here webhook-binary file, hooks.json and shell-script sendmessage.sh.
Next, run command:
docker build -t webhook-image . --tag=webhook-image && docker run --network="host" -d -p 9000:9000 --name=webhook webhook-image && docker start webhook
Next in browser open url http://
When open your site on port 9000, webhook is executed shell-script.
It's very great!!!
I'm closing the issue then.
The proposed webhook service seems like a bit more work and additional points of complexity and failure than having alert manager support script running. Can this issue be reopened as a feature request?
@mchugh19 unfortunately no:
It would be great if alert manager can support running shell scripts.
Running external scripts is the standard and flexible way to integrate with third-party systems. Definitely would like to see it supported.
https://github.com/adnanh/webhook is a generic webhook receiver written in Go, you can easily use this with alertmanager's webhooks in order to run shell commands.
@dgl I'm aware of it. That's one more service we have to run, monitor and support. It just makes system more complex and adds yet another moving part.
in case it help anyone, I do have written a blogpost for helping people using this pattern:
https://mallozup.github.io/posts/self-healing-systems-with-prometheus/
Most helpful comment
It would be great if alert manager can support running shell scripts.