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

query returning empty metric if functions are used #1986

Closed
zxwing opened this Issue Sep 13, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@zxwing
Copy link

zxwing commented Sep 13, 2016

I just notice if I use functions in an expression the response contains an empty metric, all labels are just lost. Is it by design?

My application relies on labels a lot, missing labels breaks the business logic.

Specific to my problem the function I use is avg()

@grobie

This comment has been minimized.

Copy link
Member

grobie commented Sep 13, 2016

I assume you mean in general aggregators and not functions here: https://prometheus.io/docs/querying/operators/#aggregation-operators. Aggregation operators by design combine multiple time series and produce new ones. If you don't specify a by() or without() clause they will collapse all time series into one. To avoid that, be more specific on which labels you want to make the aggregation happen.

Example: avg without(instance)(your_metric) will keep all labels except the instance label.

@zxwing

This comment has been minimized.

Copy link
Author

zxwing commented Sep 13, 2016

@grobie thanks, it starts working now; however, the name metric is still missing, is there any way to keep it? I don't need to operate on multi-series.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Sep 13, 2016

The name is only kept if it's still the same metric, for example x * 2 is no longer x so the name is removed.

@zxwing

This comment has been minimized.

Copy link
Author

zxwing commented Sep 13, 2016

got you. Thank you!

@zxwing zxwing closed this Sep 13, 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.