Alertmanager config

131 views
Skip to first unread message

David Heinz

unread,
Nov 15, 2022, 1:58:00 AM11/15/22
to Prometheus Users
Would anyone happen to have a sample Alertmanager.yml that includes the arbitrary key values here:

[ details: { <string>: <tmpl_string>, ... } | default = {
  firing:       '{{ template "pagerduty.default.instances" .Alerts.Firing }}'
  resolved:     '{{ template "pagerduty.default.instances" .Alerts.Resolved }}'
  num_firing:   '{{ .Alerts.Firing | len }}'
  num_resolved: '{{ .Alerts.Resolved | len }}'
}

I need to add a nodename value in this section, but can't seem to get the yaml right,  I would greatly appreciate any help at all.

Julius Volz

unread,
Nov 16, 2022, 7:50:36 AM11/16/22
to David Heinz, Prometheus Users
Hi,

The YAML syntax for that details portion should be:

details:
  mykey1: myvalue1
  mykey2: myvalue2

...and the default value (as indicated by your config docs snippet) would be fully written out like this:

details:
  resolved:     '{{ template "pagerduty.default.instances" .Alerts.Resolved }}'
  num_firing:   '{{ .Alerts.Firing | len }}'
  num_resolved: '{{ .Alerts.Resolved | len }}'

The docs just use a more JSON-style syntax since JSON is also a valid subset of YAML, so you could use { ... } JSON object notation as well.

Each of the values is a templateable string (as shown in the default value), so you can use variables and template functions in there to refer to e.g. alert labels and such.

Regards,
Julius

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/8b547c88-0bf5-4994-bb03-e27822deea78n%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com
Reply all
Reply to author
Forward
0 new messages