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

Why can't {} be used to match every metric? #2162

Closed
EdSchouten opened this issue Nov 4, 2016 · 3 comments
Closed

Why can't {} be used to match every metric? #2162

EdSchouten opened this issue Nov 4, 2016 · 3 comments

Comments

@EdSchouten
Copy link
Contributor

I've noticed that Prometheus contains some smartness that prevents you from running queries that match every metric. For example, running the query {} prints the following error:

Error executing query: parse error at char 2: vector selector must contain label matchers or metric name

Let's add some smartness to work around this by running {__name__=~".*"}:

Error executing query: parse error at char 16: vector selector must contain at least one non-empty matcher

You could ask yourself: why would you want to run a query that matches every metric? Well, I just want to get a rough idea of the number of metrics our Prometheus setup stores by job. Ideally I'd just want to run count({}) by (job), but now I'm forced to use workarounds like count({__name__=~"..*"}) by (job) (notice the ..*).

@brian-brazil
Copy link
Contributor

This is on purpose to reduce the chances of users accidentally hosing their Prometheus, as it's very easy to end up with such an expression while playing around.

@mprasil
Copy link

mprasil commented Nov 7, 2016

@EdSchouten use ".+" if you find "..*" too hack-ish.

@lock
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.
Projects
None yet
Development

No branches or pull requests

3 participants