Webhook Contactpoint

Hi guys,

I have a question about how to write a webhook that takes labels as inputs. For example, I have a webhook that takes a file name and executes a specific file.

My webhook looks like this: http://xxx.xx.xx.xxxx:yyyy/webhook and I should pass the file name like this: name=file.yml.

For example:

import requests

url = “http://xxx.xx.xx.xxxx:yyyy/webhook”
data = {“name”: “file.yml”}
response = requests.post(url, json=data)

How can I write this webhook in a contact point in Grafana?

Hi,
Webhooks always send the same request body that you cannot override. In there you get access to alert’s labels, annotations, and lots of other info. So maybe you’d have to create a label name and set it to file.yml in your alert? Here’s a sample webhook body.

Hi @dawiddebowski,
Thanks for your response.
In some alerts, I want to set a label, for example, ‘name’, and in the contact point, I want to pass this label (only the ‘name’) to the webhook. Is it possible to pass parameters like labels in garafana to webhook? and how to implement it in webhook contact point?

I’m really appreciative of your help, @dawiddebowski. This link is really helpful for me. In every alert, Grafana sends its labels, so I can get them in my webhook. Thanks a lot.

1 Like