Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upresult of a count() on a query that returns nothing should be 0 ? #2286
Comments
This comment has been minimized.
This comment has been minimized.
|
This is correct. You're probably looking for the |
brian-brazil
added
the
kind/question
label
Dec 15, 2016
This comment has been minimized.
This comment has been minimized.
|
@brian-brazil I'm trying to make prometheus to alert when count of the containers that match a specific pattern in a geo region drops below some number:
So this works until there are no containers of this name in the region ... then the value becomes "no data" and that's not < 4 ... so there is no alert ... I cant see how absent() may help me here... |
This comment has been minimized.
This comment has been minimized.
|
Yeah, absent() is probably the way to go. There's also count_scalar(),
which outputs 0 for an empty input vector, but that outputs a scalar
without any dimensional information.
…On Thu, Dec 15, 2016 at 6:24 PM, Lior Goikhburg ***@***.***> wrote:
@brian-brazil <https://github.com/brian-brazil> I'm trying to make
prometheus to alert when count of the containers that match a specific
pattern in a geo region drops below some number:
IF count(container_last_seen{environment="prod",name=~"notification_sender.*",roles=~".*application-server.*"}) by (geo_region) < 4
So this works until there is no containers of this name in the region ...
then the value becomes "no data" and that's not < 4 ... so there is no
alert ...
I can see how absent() may help me here...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2286 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAg1mPXncyVis81Rx1mIWiXRDe0E1Dpcks5rIXe6gaJpZM4LOTeb>
.
|
This comment has been minimized.
This comment has been minimized.
|
@juliusv yeah, I tried count_scalar() but I can't use aggregation with it. As for absent() ... I'm still out of ideas here. How would you address this use case:
The best query I could come up with is this:
The result of the query is:
Which is great... but... It can't get me a region where there are no containers (0), cause for some reason count() doesn't work for 0 elements in vector ...
|
This comment has been minimized.
This comment has been minimized.
|
Please use the prometheus-users mailing list for questions. |
grobie
closed this
Mar 5, 2017
This comment has been minimized.
This comment has been minimized.
fortman
commented
Oct 25, 2017
|
@zerthimon You might want to use 'bool' with your comparator |
This comment has been minimized.
This comment has been minimized.
baifeg
commented
Sep 6, 2018
•
|
@zerthimon The following expr works for me |
This comment has been minimized.
This comment has been minimized.
lilred
commented
Feb 21, 2019
|
Alternatively, |
zerthimon commentedDec 15, 2016
What did you do?
count(container_last_seen{name="container_that_doesn't_exist"})
What did you expect to see?
0
What did you see instead? Under which circumstances?
"no data"