Closed CubicrootXYZ closed 2 years ago
This is a great addition! Happy for you to let me know once this is ready for review.
Thanks @CubicrootXYZ, will take a look on the weekend. How do I best test this, assuming I don't have a running Prometheus instance?
Thanks @CubicrootXYZ, will take a look on the weekend. How do I best test this, assuming I don't have a running Prometheus instance?
I used the built in alertmanager in grafana, this is the test notification from there:
{
"receiver": "",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "TestAlert",
"instance": "Grafana"
},
"annotations": {
"summary": "Notification test"
},
"startsAt": "2022-04-22T19:56:18.965287262Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"fingerprint": "57c6d9296de2ad39",
"silenceURL": "http://localhost:3000/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DTestAlert%2Cinstance%3DGrafana",
"dashboardURL": "",
"panelURL": "",
"valueString": "[ metric='foo' labels={instance=bar} value=10 ]"
}
],
"groupLabels": {},
"commonLabels": {
"alertname": "TestAlert",
"instance": "Grafana"
},
"commonAnnotations": {
"summary": "Notification test"
},
"externalURL": "http://localhost:3000/",
"version": "1",
"groupKey": "{alertname=\"TestAlert\", instance=\"Grafana\"}2022-04-22 19:56:18.965287262 +0000 UTC m=+174143.108334255",
"truncatedAlerts": 0,
"orgId": 1,
"title": "[FIRING:1] (TestAlert Grafana)",
"state": "alerting",
"message": "**Firing**\n\nValue: [ metric='foo' labels={instance=bar} value=10 ]\nLabels:\n - alertname = TestAlert\n - instance = Grafana\nAnnotations:\n - summary = Notification test\nSilence: http://localhost:3000/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DTestAlert%2Cinstance%3DGrafana\n"
}
You might want to add labels (title, message) and use that as a payload to /test?token=$APPLICATION_TOKEN
Where are the top-level keys title
, state
, and message
coming from in your JSON? Is this something you added with Grafana? Just asking because the code reads as if we read title and message from the annotations of each individual alert.
Where are the top-level keys
title
,state
, andmessage
coming from in your JSON? Is this something you added with Grafana? Just asking because the code reads as if we read title and message from the annotations of each individual alert.
Yes, this seems to be added by grafana.
This PR adds a new endpoint at
/alert
that is compatible with the alertmanager webhook. Thus alerts can now be send directly to a pushbits channel without any third party involved.