Repository navigation
Closed
Description
Alertmanager version: 0.5.1
My alert configure as follows ...
ALERT PoDHighCPUUsage
IF sum(rate(container_cpu_usage_seconds_total{container_label_io_kubernetes_pod_namespace!=""}[2m])) BY (kubernetes_pod_name, kubernetes_io_hostname, container_label_io_kubernetes_pod_namespace) >= 0.2
FOR 2m
LABELS {severity="criticalup"}
ANNOTATIONS {summary="CPU usage of POD {{ $labels.kubernetes_pod_name }} {{ $labels.container_label_io_kubernetes_pod_namespace }} utilization is >= 0.4 cores (current value: {{ $value }}%)"}
webhooks setup as follows ..
- name: 'email-n-webhookup'
email_configs:
- to: 'mail-id'
send_resolved: true
webhook_configs:
- url: http://<webhook_ip>:9000/hooks/ose-webhook?in1={{.Labels.container_label_io_kubernetes_pod_namespace}}&in2={{.Labels.kubernetes_pod_name}}&in3=plus
- name: 'email-n-webhookdn'
email_configs:
- to: 'mail-id'
send_resolved: true
webhook_configs:
- url: http://<webhook_ip>:9000/hooks/ose-webhook?in1=tomi&in2=chat&in3=minus
In webhook server logs I am getting data as follows.
[webhook] 2017/04/03 10:03:17 2017-04-03T10:03:17Z | 200 | 194.078µs | 172.30.200.104:9000 | POST /hooks/ose-webhook
[webhook] 2017/04/03 10:03:17 executing /etc/webhook/ose.sh (/etc/webhook/ose.sh) with arguments ["/etc/webhook/ose.sh" "{{.labels.container_label_io_kubernetes_pod_namespace}}" "{{$labels.kubernetes_pod_name}}" "plus"] and environment [] using /etc/webhook as cwd
not as a data, its coming as a complete variable.
So I am not able to pass the value/data "labels.kubernetes_pod_name" & "labels.container_label_io_kubernetes_pod_namespace" in webhook_configs "email-n-webhookup"
Statically it worked as per "email-n-webhookdn"
I think its supported for Email as per https://www.robustperception.io/using-labels-to-direct-email-notifications/
not sure if I can use it in webhook as well ......
Please help ....
Reacted by Samuel Charbonneau
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
juliusv commentedon Apr 3, 2017
The webhook URL is not a templateable field. Instead the webhook notifier sends all metadata in the request body, as outlined in https://prometheus.io/docs/alerting/configuration/#<webhook_config>.
You can grab the labels from there in your webhook implementation.
Closing, as this is hopefully answered. If not, please ask questions on the users mailing list instead of opening an issue: https://prometheus.io/community/
prasenforu commentedon Apr 3, 2017
Thanks.
Don't you think its a enhancement.
juliusv commentedon Apr 3, 2017
I can reopen this as a feature request, but it started out as a question.
[-]Using labels in Alertmanager webhook[/-][+]Allow templating in the webhook URL[/+]brian-brazil commentedon Apr 3, 2017
This wouldn't make sense feature wise. The webhook is meant to work in exactly one way, with the other end specifically designed to accept what we send.
The other end already has all the information it needs.
juliusv commentedon Apr 3, 2017
That's what I thought too. Confirmed then...
prasenforu commentedon Apr 4, 2017
Like other config where url used that all are customised template.
Why not webhook? and can't be a static all time.
Let it be open for further discussion..
juliusv commentedon Apr 4, 2017
@prasenforu The reasoning here goes:
prasenforu commentedon Apr 4, 2017
OK.
Thanks.
Let me explain why ?
I am using prometheus in containers platform (kubernetes) where things are changing very dynamically.
I do agree your point.
Can you please suggest any alternative solution where I can pass labels in that url.
Otherwise I have to write for each conrainer separate webhook which is not a good idea.
Basically I want to make global.
Anyway thanks for your continuous support.
brian-brazil commentedon Apr 4, 2017
Uhm, write a webhook that does this and sends out the requests in the format you need.
prasenforu commentedon Apr 7, 2017
Finally able to setup webhook without templating webhook url.
Thanks all to rethink on this.
Bydefault webhook resolve option is true.
Is that mean when it resolve it will fire same webhook.
Is that understanding correct?
juliusv commentedon Apr 7, 2017
7 remaining items
freeseacher commentedon Oct 18, 2020
@nehalraf Have you found a solution for templating opsgenie's heartbeats?
mojitaleghani commentedon Aug 26, 2024
Dear @brian-brazil
Hi
do you remember how did you do that template with webhook??
nourspace commentedon Nov 6, 2025
The solution is to create multiple routes with label matchers and receivers with different hardcoded urls. It gets messy. While allowing a templated url would allow using alert labels to construct the correct webhook url.
waltherlee commentedon Dec 2, 2025
This isn't the case anymore. The alertmanager supports templating in some URL fields now, for example, SlackAction.URL and PushoverConfig.URL, so I think we should re-evaluate adding support for this.
I'm reopening this issue as a feature request instead of creating a new one.
I think this can be a small-ish change. I can try and send a PR in a few days.
waltherlee commentedon Jan 5, 2026
PR Merged ✅