Hello,
I have set up a Webhook to receive Grafana alert notification. The alert payload I am receiving looks like the one from Grafana’s webhook documentation
My question is how do we uniquely identify a rule based on info in this payload? I am thinking about “ruleId” but I am not sure if ruleId stays the same forever for a rule after it is created.
Can someone confirm if ruleId stays the same after rule creation?
If not, then which field in the payload should I use instead to uniquely identify a rule?
Thanks
Hi,
The ruleId is what are you looking for
Hi Daniel,
Thank you for getting back to me. A follow up question, do you know where I can find ruleId to rule mapping? I tried to find it on the Grafana’s web ui but no luck.
No realy, you needs inspect de json model of the dashboard
Where in the json model of the dashboard can you find that? I’m seeing notifications with a ruleId
of 295
but when view the dashboard json I can’t locate it:
{
"alertRuleTags": {},
"conditions": [
{
"evaluator": {
"params": [
10
],
"type": "gt"
},
"operator": {
"type": "and"
},
"query": {
"params": [
"A",
"15m",
"now"
]
},
"reducer": {
"params": [],
"type": "avg"
},
"type": "query"
}
],
"executionErrorState": "alerting",
"for": "60m",
"frequency": "15m",
"handler": 1,
"message": "Prometheus is taking a long time to gather metrics for some pods. If it starts to take longer than 15 seconds, we will lose those metrics entirely.",
"name": "Prometheus metrics scrape duration alert",
"noDataState": "alerting",
"notifications": [
{
"uid": "000000006"
},
{
"uid": "mNi6JT2Gz"
}
]
}
It can be found from the response of the API api/ruler/grafana/api/v1/rules
, checked in browser inspect.
can also be passed in annotations, choose Alert ID from the dropdown and add {{$labels.__alert_rule_uid__}}
, it will then come under CommonAnnotations in webhook payload.
1 Like