I am trying to send Alertmananger alerts to Slack and I am successful in doing that with my customized template.
But now I want to send alerts to different channels and thus selecting different webhook from the configuration file and I am not able to do so and getting
component=configuration msg="Loading configuration file failed" file=/etc/alertmanager/config/alertmanager.yaml err="unsupported scheme \"\" for URL"
I am picking the webhook from a template file and the issue is mostly with the loading of the variable "slack.myorg.webhook"
Alertmanager.yaml
global:
resolve_timeout: 5m
slack_api_url: '{{ template "slack.myorg.webhook" . }}'
route:
group_by: ['alertname']
...
...
...
templates: ['/etc/alertmanager/config/*.tmpl']
slack-myorg-template.tmpl
I will add my logic to select webhook on some labels later as of now just loading via a template
# To identify from which cluster the alerts are comming
{{ define "slack.myorg.username" }}Minikube{{ end }}
# select webhook
{{ define "slack.myorg.webhook" }}https://hooks.slack.com/services/XXX/XX/XX{{ end }}
The only issue if slack.myorg.webhook is not perfectly loading into slack_api_url by calling '{{ template "slack.myorg.webhook" . }}'.
Other things I tried
slack_api_url
(as well as api_url
from slack_config) don't support templating.
https://github.com/prometheus/alertmanager/issues/2207#event-3127085200