Skip to content

Allow templating in the webhook URL #684

@prasenforu

Description

@prasenforu

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 ....

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions