HTTP POST JSON payload from AlertManager to Webhook

12,287 views
Skip to first unread message

BlueChips23

unread,
Aug 2, 2018, 4:47:32 PM8/2/18
to Prometheus Users
I am trying to integrate the AlertManager to send the alerts to a webhook through a HTTP POST. From https://prometheus.io/docs/alerting/configuration/#%3Cwebhook_config%3E, I see an example of what the JSON payload as shown below: 

{
  "version": "4",
  "groupKey": <string>,    // key identifying the group of alerts (e.g. to deduplicate)
  "status": "<resolved|firing>",
  "receiver": <string>,
  "groupLabels": <object>,
  "commonLabels": <object>,
  "commonAnnotations": <object>,
  "externalURL": <string>,  // backlink to the Alertmanager.
  "alerts": [
    {
      "status": "<resolved|firing>",
      "labels": <object>,
      "annotations": <object>,
      "startsAt": "<rfc3339>",
      "endsAt": "<rfc3339>",
      "generatorURL": <string> // identifies the entity that caused the alert
    },
    ...
  ]
}

I have three questions:
  1. Is there a way for AlertManager to send the payload as urlencoded instead of JSON format?
  2. How do I modify this JSON payload to include custom key-value pairs?
  3. Is there an example of the JSON payload that I can look at to understand what are all the different key/value pairs typically included in this alert payload?

Simon Pasquier

unread,
Aug 3, 2018, 3:55:10 AM8/3/18
to BlueChips23, Prometheus Users
On Thu, Aug 2, 2018 at 10:47 PM, BlueChips23 <bluech...@gmail.com> wrote:
I am trying to integrate the AlertManager to send the alerts to a webhook through a HTTP POST. From https://prometheus.io/docs/alerting/configuration/#%3Cwebhook_config%3E, I see an example of what the JSON payload as shown below: 

{
  "version": "4",
  "groupKey": <string>,    // key identifying the group of alerts (e.g. to deduplicate)
  "status": "<resolved|firing>",
  "receiver": <string>,
  "groupLabels": <object>,
  "commonLabels": <object>,
  "commonAnnotations": <object>,
  "externalURL": <string>,  // backlink to the Alertmanager.
  "alerts": [
    {
      "status": "<resolved|firing>",
      "labels": <object>,
      "annotations": <object>,
      "startsAt": "<rfc3339>",
      "endsAt": "<rfc3339>",
      "generatorURL": <string> // identifies the entity that caused the alert
    },
    ...
  ]
}

I have three questions:
  1. Is there a way for AlertManager to send the payload as urlencoded instead of JSON format?

No
 
  1. How do I modify this JSON payload to include custom key-value pairs?

You can't change the format of the JSON payload.
 
  1. Is there an example of the JSON payload that I can look at to understand what are all the different key/value pairs typically included in this alert payload?

Here is a example:

{
  "receiver": "webhook",
  "status": "firing",
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alertname": "Test",
        "dc": "eu-west-1",
        "instance": "localhost:9090",
        "job": "prometheus24"
      },
      "annotations": {
        "description": "some description"
      },
      "startsAt": "2018-08-03T09:52:26.739266876+02:00",
      "endsAt": "0001-01-01T00:00:00Z",
      "generatorURL": "http://simon-laptop:9090/graph?g0.expr=go_memstats_alloc_bytes+%3E+0\u0026g0.tab=1"                                                                                  
    }
  ],
  "groupLabels": {
    "alertname": "Test",
    "job": "prometheus24"
  },
  "commonLabels": {
    "alertname": "Test",
    "dc": "eu-west-1",
    "instance": "localhost:9090",
    "job": "prometheus24"
  },
  "commonAnnotations": {
    "description": "some description"
  },
  "externalURL": "http://simon-laptop:9093",
  "version": "4",
  "groupKey": "{}:{alertname=\"Test\", job=\"prometheus24\"}"
}

 

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/503e09bc-3678-4d82-8ac9-14dc12cc03e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

zha...@ebay.com

unread,
Jan 10, 2019, 7:09:51 AM1/10/19
to Prometheus Users
Reply all
Reply to author
Forward
0 new messages