count() returns no labels, and it also returns no timeseries when it has no
input (rather than a timeseries with value zero, which I had naïvely
expected). So this is simpler again:
absent(jenkins_up) and count(up{job="jenkins"})
On Monday, 4 October 2021 at 15:29:14 UTC+1 Dan S wrote:
> Thanks Brian for the advice! I found the `absent() and absent()` seemed to
> work well.
>
> Also Ben - thank you - I did take your advice as well re: making multiple
> layers of alerts, and didn't know about
> prometheus_target_scrape_pool_targets,
> which could be useful in other ways as well.
>
> Appreciate it!
>
> Dan
>
>
> On Mon, Oct 4, 2021 at 5:07 PM Brian Candler <[email protected]> wrote:
>
>> On Sunday, 3 October 2021 at 22:50:59 UTC+1 [email protected] wrote:
>>
>>> Trying to manipulate alerts with absent() tends to behave badly.
>>>
>>
>> Aside: I found it a bit surprising at first that count() and sum() across
>> an empty instant vector give an empty result, rather than 0. I don't see
>> that behaviour explicitly called out here
>> <https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators>,
>>
>> but I guess it makes sense when you think about what "count by", "sum by"
>> or "count_values" would have to do, when given no input.
>>
>> You can of course make it work the other way if required: e.g.
>> "count(foo) or vector(0)"
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Prometheus Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/prometheus-users/gi8GtrBMMMk/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/prometheus-users/4adf9702-adbc-43be-837e-794c6e009d2bn%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/prometheus-users/4adf9702-adbc-43be-837e-794c6e009d2bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
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/da11741e-52c5-4cf4-baa3-deb3daed7b38n%40googlegroups.com.