alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

alerts templates doesn't get updated {{ $value }} value

Open fvigotti opened this issue 10 years ago • 4 comments

Hi, as said in title, alerts template always get the first $value that is seen when the first alert gets fired, I has been unable to get a retrieve in any way an updated $value for the message output.

Having a template like this

{{ define "__alert_testing_check" }}
--------------------------------------------------------------------------------------

{{ range $key, $value := .Alerts }}
KV= {{ $key }} =  {{ $value }} <br><br>
{{ end }}
{{ end }}

and alert like this :

ALERT testvalue
  IF (process_cpu_seconds_total) > 0
  LABELS {
    severity = "check",
    valuecur = "label value",
    bbb = "$value",
    ccc = "{{ $value }} "
  }
  ANNOTATIONS {
    summary = "memstats free",
    description = "process_cpu_seconds_total",
    valuecur = "annotations value",
    bbb = "$value",
    ccc = "{{ $value }} "
  }

generated template output is this

[12:46 PM] prometheus_testing · AlertManager: --------------------------------------------------------------------------------------
KV= 0 =  {firing map[bbb:$value ccc:0.79  instance:localhost:9090 job:prometheus monitor:codelab-monitor severity:check valuecur:label value alertname:testvalue] map[bbb:$value ccc:0.79  description:process_cpu_seconds_total summary:memstats free valuecur:annotations value] 2016-11-16 12:46:52.803 +0100 CET 0001-01-01 00:00:00 +0000 UTC http://w2:9090/graph?g0.expr=%28process_cpu_seconds_total%29+%3E+0&g0.tab=0}

[12:47 PM] prometheus_testing · AlertManager: --------------------------------------------------------------------------------------
KV= 0 =  {firing map[ccc:0.79  instance:localhost:9090 job:prometheus monitor:codelab-monitor severity:check valuecur:label value alertname:testvalue bbb:$value] map[ccc:0.79  description:process_cpu_seconds_total summary:memstats free valuecur:annotations value bbb:$value] 2016-11-16 12:46:52.803 +0100 CET 0001-01-01 00:00:00 +0000 UTC http://w2:9090/graph?g0.expr=%28process_cpu_seconds_total%29+%3E+0&g0.tab=0}

the problem is that value ccc does not update, seems that value gets compiled on first alert than remain the same.. ( when I open the browser at /alerts the VALUE is correctly refreshed , It's only the template that seems to get the first seen $value .. ) Is this a bug or I am missing something ?

PS:

alertmanager: version 0.5.0 (branch: master, revision: a91fe17ddf0a57c627e2cfcdaa0ab364b1ab3e04)   build user:       root@f336dcc453a4   build date:       20161101-18:10:50   go version:       go1.7.3

prometheus prometheus, version 1.3.0 (branch: master, revision: 18254a172b1e981ed593442b2259bd63617d6aca)   build user:       root@d363f050a0e0   build date:       20161101-17:06:27   go version:       go1.7.3

fvigotti avatar Nov 16 '16 13:11 fvigotti

Are you referring to the Alertmanager or Prometheus UI when you say the annotation value is correctly updated?

fabxc avatar Nov 21 '16 09:11 fabxc

I am having the same issue:

  • Alerts out of alertmanager using $value seem to always have the first value that occured
  • Looking at /alerts on the prometheus server, you can see that the value correctly updates
  • Looking at /alerts on the alertmanager server the source message reflects the first instance of the alert

polyisobutylene avatar Nov 21 '16 19:11 polyisobutylene

exactly as described by @polyisobutylene

fvigotti avatar Nov 22 '16 10:11 fvigotti

The issue is on the Prometheus side and will be fixed with the next release. Thanks for reporting.

fabxc avatar Nov 22 '16 14:11 fabxc