You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clicking 'silence alert' buttons on Alerts page does nothing #21
Thanks reporting this! This stumped me for a while, especially since I couldn't reproduce it locally at first.
Turns out, this bug happens when alerts with missing JSON fields are sent to alertmanager. The alerts HTML template contains sections like <a href="{{.Alert.Payload.GeneratorURL}}">. The GeneratorURL is actually a key in a map[string]string which is populated from the alert payload data sent to the alertmanager via JSON over HTTP. Currently, alertmanager assumes that all alerts must set correct GeneratorURL and AlertingRule properties in this payload hash. When this doesn't happen, the Go templating engine crashes during render when accessing a missing JSON field in this manner:
Of course, sending corrupt/incomplete alert messages to alertmanager should result in the alerts not being accepted (sender gets an HTTP error) instead of the Alerts page not rendering correctly anymore.
I'll look into fixing that!
For now, I guess you must be using some outdated version of Prometheus (or manual way) to send alerts to alertmanager? The JSON field names that Prometheus sends changed in October: prometheus/prometheus@6eecee5.
And I correct myself: instead of rejecting alerts with missing Payload properties, all Payload properties should be considered as optional, since they are not strictly required by anything else than the template.
Ah. Actually, the only problem with non-existing values in templates arises when they are passed to functions like {{(truncate .Alert.Payload.GeneratorUrl 40)}}, where truncate is a function which expects a string. I'll wrap a conditional around that.
Yeah, I was just testing the system by manually POSTing an alert in, since I hadn't even successfully compiled Prometheus yet (I'm writing a bug up about the Docker build).
Activity
juliusv commentedon Jan 10, 2015
Thanks reporting this! This stumped me for a while, especially since I couldn't reproduce it locally at first.
Turns out, this bug happens when alerts with missing JSON fields are sent to alertmanager. The alerts HTML template contains sections like
<a href="{{.Alert.Payload.GeneratorURL}}">. TheGeneratorURLis actually a key in amap[string]stringwhich is populated from the alert payload data sent to the alertmanager via JSON over HTTP. Currently, alertmanager assumes that all alerts must set correctGeneratorURLandAlertingRuleproperties in this payload hash. When this doesn't happen, the Go templating engine crashes during render when accessing a missing JSON field in this manner:(set
-logtostderrto see logging lines on stderr)Of course, sending corrupt/incomplete alert messages to alertmanager should result in the alerts not being accepted (sender gets an HTTP error) instead of the Alerts page not rendering correctly anymore.
I'll look into fixing that!
For now, I guess you must be using some outdated version of Prometheus (or manual way) to send alerts to alertmanager? The JSON field names that Prometheus sends changed in October: prometheus/prometheus@6eecee5.
juliusv commentedon Jan 10, 2015
For reference, this is a working example alert JSON containing one sample alert:
Save this to an
alerts.jsonfile, then send it to your alertmanager like this:juliusv commentedon Jan 10, 2015
And I correct myself: instead of rejecting alerts with missing
Payloadproperties, allPayloadproperties should be considered as optional, since they are not strictly required by anything else than the template.juliusv commentedon Jan 10, 2015
Ah. Actually, the only problem with non-existing values in templates arises when they are passed to functions like
{{(truncate .Alert.Payload.GeneratorUrl 40)}}, wheretruncateis a function which expects a string. I'll wrap a conditional around that.swsnider commentedon Jan 10, 2015
Yeah, I was just testing the system by manually POSTing an alert in, since I hadn't even successfully compiled Prometheus yet (I'm writing a bug up about the Docker build).
juliusv commentedon Jan 10, 2015
@swsnider Ah, does a simple non-Docker
make buildwork for you though?The Docker build is contributed by our friend at Docker, @discordianfish
swsnider commentedon Jan 10, 2015
Yes, it does, but I'm using a Mac, and need to build for Linux, and cross compilation is difficult otherwise because procfs requires cgo :(
juliusv commentedon Jan 10, 2015
Aha! Yes, a majority of core contributors is completely on Linux even on their laptops, so any help in that area is greatly appreciated :)
Parse filter directly in alerts route (prometheus#21)
Merge pull request prometheus#21 from simonpasquier/aos-bump-0.16.2
dep: Manually upgrade golang.org/x/net (#3674) (#3811)