magenta-aps / check_prometheus_metric

Nagios plugin for alerting on Prometheus query results.
Apache License 2.0
46 stars 10 forks source link

Comparison with negative values in result #10

Closed isaiasanchez closed 2 years ago

isaiasanchez commented 3 years ago

I got a metric with positive values for warning and critical threshold, but when I receive a negative value as result it display a CRITICAL ALARM and negative value is minor than any positive one, so it should be an OK result.

I must fix this adding the condition "> 0" to promQL query and return only positive results, but then I got NULL vector, so I must add "on() vector(0)" to return the zero vector, but i would like to display the negative value because it gives some information, even if it's not an alarm.

Note: Waiting for next release with -E option to remove "on() vector(0)"

Skeen commented 3 years ago

The -E option has been released.

As for negative query values, I do not seem able to reproduce the issue you're seeing. As far as I can see, it works as expected, see: #11

I imagine your issue is that you're using the old syntax for defining warning and critical intervals, i.e. the single float -w 4 instead of the interval syntax: -w ~:4.

The old syntax -w 4 means [0, 4], while -w ~:4 means ]-inf, 4].

isaiasanchez commented 2 years ago

It works, but I must use double quotes: -w "~:4" -c "~:10". thanks