Alertmanager - Retrieve receiver's Email addresses from an external source

23 views
Skip to first unread message

faroukelm...@gmail.com

unread,
Aug 18, 2022, 7:07:55 AM8/18/22
to Prometheus Users
Hi,

we are monitoring a bunch of hosts with Prometheus, forwarding the alerts to the alertmanager and from there to one Email receiver.

We are currently evaluating the possibility to forward the Emails, generated by the AlertManager, to different Email addresses, depending on the host impacted by the alert. We don't want however to keep the mapping "host <-> Email address" hardcoded in the alertmanager config. This information can be retrieved via a REST call.

I am wondering if there is a possibility for the alertmanager to make external http calls,  before triggering an alert, and use the returned information (Email address) as a destination of the Emails. Another option would be to include the information retrieved in the message sent to a webhook receiver.

Does someone know if such a use case can be implemented using Prometheus/Alertmanager? Any ideas are welcome.

Regards
Farouk

Brian Candler

unread,
Aug 18, 2022, 12:33:16 PM8/18/22
to Prometheus Users
Use the webhook functionality: write your own webhook receiver which performs whatever logic you like and then sends an email.

Personally though, I wouldn't do this.  I would create separate receivers in alertmanager for each email address, and then use alert routing rules (which can be controlled by labels) to select the correct receiver.  If the list of receivers is long or frequently changing, then I'd automate the generation of the alertmanager config from some external source-of-truth database.
Reply all
Reply to author
Forward
0 new messages