Parsing grafana alarm payload data for notification templates

68 views Asked by At

I'm using grafana (ver 10) and prometheus, and I have a query for meausuring memory load and generate an alarm if some percentage exceeds

query is working fine, and I can get the memory load without problem. also my alarm is firing without problem enter image description here

My problem is creating a meaningful email message. For this I'm trying to create a notification template, but I couldn't parse the info.

This is my payload data, from firing alarm

[
  {
    "annotations": {
      "__orgId__": "1",
      "__value_string__": "[ var='A' labels={instance=1.1.1.1:9100, job=node} value=96.93493522237222 ], [ var='B' labels={instance=1.1.1.1:9100, job=node} value=1 ]",
      "__values__": "{\"A\":96.93493522237222,\"B\":1}",
      "summary": "\"High RAM usage detected on 1.1.1.1:9100\""
    },
    "labels": {
      "__alert_rule_uid__": "fb5f82db-22bc-4d30-bdb9-7df464340331",
      "alertname": "Ram usage",
      "grafana_folder": "MyCustom Alerts",
      "instance": "1.1.1.1:9100",
      "job": "node"
    },
    "startsAt": "2024-02-18T16:21:00.000Z",
    "endsAt": "2024-02-18T16:41:00.000Z"
  }
]

Here I'm just trying to parse value of 96.93 from

"__values__": "{\"A\":96.93493522237222,\"B\":1}"

I read the go template page in grafana but couldn't find a way.

0

There are 0 answers