prometheus / alertmanager

Prometheus Alertmanager
https://prometheus.io
Apache License 2.0
6.68k stars 2.16k forks source link

Alertmanager sent extra line in JSON payload to webhook endpoint #2418

Closed willz9683 closed 4 years ago

willz9683 commented 4 years ago

What did you do? Alertmanager integration with external webhook API interface. Use postman to analysis alertmanager POST request.

What did you expect to see? alert JSON message in one string of POST request payload

What did you see instead? Under which circumstances? alertmanager send extra empty line (newline?) as part of the payload. Payload is considered as invalid JSON format.

Environment

route: group_by: ['alertname', 'cluster', 'service'] group_wait: 5s group_interval: 5m repeat_interval: 3h receiver: "snmp_webhook" routes:

inhibit_rules:

receivers:


* Logs:

level=error ts=2020-11-09T15:10:22.946Z caller=dispatch.go:301 component=dispatcher msg="Notify for alerts failed" num_alerts=3 err="cancelling notify retry for \"webhook\" due to unrecoverable error: unexpected status code 400: http://"


postman analysis snapshots are attached.

![alertmanager_post_payload](https://user-images.githubusercontent.com/70406217/98559429-9a95ee80-2274-11eb-973c-d7ae67e7d82d.png)
roidelapluie commented 4 years ago

I think that this is the receiver's fault. We use standard go tools for this, and they are accepted by the majority of receivers. What is the receiver?

willz9683 commented 4 years ago

The receiver is DMaaP Message Router

simonpasquier commented 4 years ago

Reading https://tools.ietf.org/html/rfc7159 I see nothing wrong here. As Julien says, we use the standard Go library to produce the JSON payload and it would be surprising if it were generating incompatible payload.