alertName in grafana annotations

Hello,

Sorry for my newbie question, but i can’t find the way to set alertName in Grafana annotations, may be someone can help me.

Grafana version:
Version 9.3.1 (commit: 89b365f8b1, branch: HEAD)
API path:
/api/annotations?
Example:
[
{
“id”: 1349,
“alertId”: 493,
“alertName”: “”,
“dashboardId”: 0,
“dashboardUID”: null,
“panelId”: 0,
“userId”: 0,
“newState”: “Alerting”,
“prevState”: “Pending”,
“created”: 1675309928427,
“updated”: 1675309928427,
“time”: 1675309920000,
“timeEnd”: 0,
“text”: “< redacted >”,
“tags”: ,
“login”: “”,
“email”: “”,
“avatarUrl”: “”,
“data”: {
“values”: {
“B”: 0,
“C”: 1
}
}
},


]

All annotations has “alertName”: “”, but i want to set some meaning in this field, is it possible ?

Thanks,
Aleksei

Alert name is not included in Annotations object, you have to pick it in Labels object.
For example if you use Grafana templating:
{{ .Annotations.summary }}: gets the field summary from Annotations
{{ .Labels.alertname }}: gets the alert name from Labels

First of all, thanks for your response.
My final goal is to create dashboard with alerts history.
Currently for this purpose i use JSON Api plugin for using grafana/api/annotations as datasource and my panel almost done, except it shows alertID, but not alertName.

panel:

settings:

If i understand you correctly, i have to find another way to do this, due to that fact that alertName in Annotation object always will be empty string, am i right ?

Thanks for the answer, in this case you need to use an additional API.
It seems this API is fit to get alert name: Alerting HTTP API | Grafana documentation

Ok, thanks for your advice, i will check what i can do with this API.

1 Like