Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with count_values()? #1849

Closed
Hetkoekje opened this Issue Jul 27, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@Hetkoekje
Copy link

Hetkoekje commented Jul 27, 2016

Hi,

I've been using Prometheus with Cadvisor and node_exporter to monitor some dockers, currently i'm attempting to write a query to detect when a docker container goes down.
So far I've found this query that almost does the job to my liking:
count(container_last_seen{image!=""})

This detects the amount of running containers nicely, but if prometheus is running and a docker goes down after prometheus is already running, the metric isn't removed.
This is cadvisor's part and maybe it is designed this way, because what i do notice is that the value of metric changes if the docker goes down!
Then I found the count_values() operator instead of the count() in the documentation of your website and was thinking, that's it!

Unfortunately, when I replaced count() with count_values() I received the following error:
count_values(container_last_seen{image!=""})

Error executing query: parse error at char 44: unexpected ")" in aggregation, expected ","

Is this working as intended? If so, could you please clarify this a bit in your documentation and maybe put it in another category as count() or something? Because at this time, it seems like they can both be used in the same way (syntax wise).
If not, a bug is hereby reported 😄

@grobie

This comment has been minimized.

Copy link
Member

grobie commented Jul 27, 2016

Check the documentation of the count_values(), there is a required parameter for specifying the label name which will hold the unique value. In you case, something like count_values("timestamp", container_last_seen{image!=""}).

@Hetkoekje

This comment has been minimized.

Copy link
Author

Hetkoekje commented Jul 28, 2016

Thank you! That did the job!
Seeing the result of the query, it also actually makes sense that you need to add a label parameter.

It still isn't very clear to me though where exactly this is documented, but that probably is a fault on my part. I was looking at this page and following the logic here, to me it seemed that it could be used the same way as count()

But again, this is probably a fault on my part.
Thank you again for your quick response and making this awesome tool!

@Hetkoekje Hetkoekje closed this Jul 28, 2016

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.