Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST valid JSON object to alertmanager #1694

Open
diogogmt opened this Issue May 31, 2016 · 12 comments

Comments

Projects
None yet
5 participants
@diogogmt
Copy link

diogogmt commented May 31, 2016

The notifier.send function posts an array of alerts to the alert manager which is not a valid JSON object.
The format being posted is:

[{...}]

Instead of:

{alerts: [{...}]}
@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jun 1, 2016

👍 thanks for reporting. Indeed very incorrect.

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jun 2, 2016

For my understanding, is it a bad design pattern for the top-level type of a transferred API value to a JSON array instead of an object? For later extensibility I guess?

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jun 2, 2016

Well, for browsers it was always considered bad practice due to security concerns (http://flask.pocoo.org/docs/0.10/security/#json-security).
Not directly the case here but one should just stick with best practice I think.

Plus extensibility as you said. I'm in favor of fixing that. We can make Alertmanager accept both for a while.

@diogogmt

This comment has been minimized.

Copy link
Author

diogogmt commented Jun 2, 2016

Exactly, I would say that extensibility is the biggest benefit.

The only reason we came across this was that in our application we were playing with the idea of receiving the alerts directly from prometheus instead of letting the alert-manager manage the aggregates.
However, when we pointed prometheus to send the alerts to our own internal server we had to make a little hack to be able to deserialize the body data to our struct since it wasn't coming as a JSON object but as a JSON array instead.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jun 28, 2016

We should really resolve this for 1.0.0.
Ideas/opinions on migration path or breakage?

@brian-brazil @juliusv @beorn7

@fabxc fabxc added this to the v1.0.0 milestone Jun 28, 2016

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jun 28, 2016

I'm unsure on this, tending towards migration path for a month or so.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jun 28, 2016

That brings the question of which direction the migration path should go and how exactly it would look like.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jun 28, 2016

It has to be on the AM side accepting both, otherwise we'd be talking a flag on the Prometheus side.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jul 3, 2016

Discussed this some more. As we might have to make adjustments with subsequent AM versions, I'll remove this from the 1.0.0 milestone.

For Prometheus <> AM communication it works fine. The custom use case is something we want to support but rare enough currently, that it doesn't justify the hassle of supporting 3 different protocols for talking to AM in the end.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 10, 2017

@brian-brazil why on the 2.x milestone? This first needs AM changes, which would accept both for a while anyway.
It has not caused any practical problems so far, so I see no rush. It would be a compatibility matrix thing anyway. So I see no relation to the Prometheus major version.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 10, 2017

It's on 2.x as if we're going to fix it we'll need breaking changes, so we need to decide if they're going to be in 2.x. As it stands 3.x seems more likely, but I wanted to put it on the table.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 10, 2017

As it's not an atomic change to one component and hasn't caused practical problems so far, let's put it off.

@brian-brazil brian-brazil removed this from the v2.x milestone Aug 11, 2017

@fabxc fabxc removed the dev-2.0 label Sep 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.