Ah, that makes sense! Thanks for the explanation, I'm new to Prometheus so 
it wasn't obvious to me.

If it helps the next newbie, I made a pull request to add a bit more 
explicit documentation about this, to clarify the parts that confused 
me: https://github.com/prometheus/prometheus/pull/7141


On Friday, April 17, 2020 at 1:43:25 PM UTC+1, Brian Candler wrote:
>
> 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/43672c22-bed6-40bf-aeff-1cd82d962e16%40googlegroups.com.

Reply via email to