On Friday, 17 April 2020 12:46:01 UTC+1, Alex Rosen wrote:
>
> This page 
> <https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/> 
> says: 
> "The $value variable holds the evaluated value of an alert instance."
>
> It would be great if this also included a more explicit definition, 
> because this definition isn't obvious to me. For example, if I have:
>
>
> expr: sum(increase(some_counter[3h])) by (foo) < 1
>
>
> Which part of this is the $value? It can't be the entire expression, 
> because that's just a boolean value. Is it everything to the left of the 
> comparison operator?
>

It *is* the value of the entire expression.

The prometheus operator "a < b" gives the value of the left-hand side if 
it's less than b (scalar, or timeseries with exactly matching label set), 
or no result if not.  See comparison operators 
<https://prometheus.io/docs/prometheus/latest/querying/operators/#comparison-binary-operators>
.

You can try this for yourself in the PromQL expression evaluator in the 
prometheus UI: e.g.

rate(node_network_receive_bytes_total[2m]) > 10000

You'll see line segments where the condition is true, and gaps where it's 
false.

[image: png1.png]

 
There is another form: "a < bool b", which gives 0 for false and 1 for 
true.  In that case, the timeseries always exists, and $value will be 
either 0 or 1 (which for alerts makes it less useful in annotations)

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/859c335f-a765-4a23-b466-8c698de94c39%40googlegroups.com.

Reply via email to