Skip to content

web api: handle alert with Infinity/NaN values#5582

Merged
brian-brazil merged 2 commits intoprometheus:masterfrom
holycheater:json-infinity-fix
May 21, 2019
Merged

web api: handle alert with Infinity/NaN values#5582
brian-brazil merged 2 commits intoprometheus:masterfrom
holycheater:json-infinity-fix

Conversation

@holycheater
Copy link
Contributor

@holycheater holycheater commented May 20, 2019

The problem:

The solution I see is to return 0 instead of Infinity/NaN values.

There is a pull request (#5303), but it is not correct and seems to be abandoned

@brian-brazil
Copy link
Contributor

brian-brazil commented May 20, 2019 via email

@simonpasquier
Copy link
Member

This isn't the correct change: the solution would be to return a string value, see #5303 (review).

@holycheater
Copy link
Contributor Author

You mean return number if it is valid or string if it is not?

@brian-brazil
Copy link
Contributor

brian-brazil commented May 20, 2019 via email

@holycheater
Copy link
Contributor Author

It will still break clients which expect a number, I can fix go client, but I don’t know about others. Are you ok with that?

@brian-brazil
Copy link
Contributor

Yes, that's acceptable here and in line with what we do for the query api.

Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
@holycheater
Copy link
Contributor Author

I've updated api to return alert value as a string.
Also made a PR in client_golang: https://github.com/prometheus/client_golang/pull/585/files
The resulting value can be parsed with strconv.ParseFloat if neccessary

@brian-brazil
Copy link
Contributor

Looks good, docs also need updating,

Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
@brian-brazil brian-brazil merged commit d6a4daa into prometheus:master May 21, 2019
@brian-brazil
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants