grafana / alerting

Set of libraries used to build alerting systems at Grafana - including the Alertmanager.
GNU Affero General Public License v3.0
47 stars 41 forks source link

Templating: allow to transform json text to object #166

Open diorcety opened 6 months ago

diorcety commented 6 months ago

A custom annotation or label with json as text should be allow to transform to object. For example

[
  {
    "annotations": {
      "summary": "Instance instance1 has been down for more than 5 minutes",
      "data": "{\"field1\": \"value1\"}"
    },
    "labels": {
      "instance": "instance1"
    },
    "startsAt": "2024-03-12T14:09:43.689Z"
  }]

we should be allowed to do something like that in template:

{{ range (data .Annotations.data).SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
diorcety commented 6 months ago

https://github.com/diorcety/alerting/commit/c36cf1207d36e2bda54115d8000c4ec092870f1c