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 upSupport label_replace() on range vectors? #2671
Comments
juliusv
added
area/usability
component/promql
kind/enhancement
labels
May 1, 2017
This comment has been minimized.
This comment has been minimized.
|
I'm against having a function of this nature. It's expected that you know your metric names, and all uses cases we've seen for this so far were where the user had encoded a label value into the metric name. I don't think we should be adding features to work around bad data modelling - particularly as we already have metric relabelling. I'm against functions' return types and semantics varying depending on the type of input arguments, that's just going to cause confusion. Finally we currently have no functions that return range vectors. I'd like to keep things that way, particularly as I expect that'll mess up optimisations that LTSes will be doing. |
This comment has been minimized.
This comment has been minimized.
|
Ok, agreed for now - let's see if a more urgent need for this comes up ever again. Closing for now. |
juliusv
closed this
May 1, 2017
tobilarscheid
referenced this issue
Jul 21, 2017
Open
Metrics generated from e.g. @Timed or @ExceptionMetered have inconvenient names #1165
This comment has been minimized.
This comment has been minimized.
fortman
commented
Oct 11, 2017
|
So the use case still exists where you want to change the value of a label, having nothing to do with a metric name. Our use case: We are using cadvisor to pull in docker statistics. We are showing the image name in a grafana dashboard. The problem is our docker image names are fully qualified so they are on the long side and hard to read in grafana. The naming convention is outside my control, so when I found the label_replace function I got really excited. The following worked: label_replace(container_cpu_user_seconds_total_counter{image!=""}, "image", "$1", "image", "./(.)") However our grafana dashboard requires a ranged vector(because we are doing an irate), and the the following does not work label_replace(container_cpu_user_seconds_total_counter{image!=""}[1m], "image", "$1", "image", "./(.)") Was excited, but now I get to live with unreadable grafana dashboards and management on my .... well you know. |
This comment has been minimized.
This comment has been minimized.
fortman
commented
Oct 11, 2017
|
n/m, wrapping the label_replace around the irate seems to work. Might still be useful, but I worked around it. |
This comment has been minimized.
This comment has been minimized.
wentwog
commented
Mar 4, 2018
This comment has been minimized.
This comment has been minimized.
deeTEEcee
commented
Nov 21, 2018
|
working with rabbitmq + kubernetes and a specific queue, the pod names are switching. I'd like to use |

juliusv commentedMay 1, 2017
Sometimes you might want to do something like
rate({__name__=~".*_total"}[1m]), but since this would lose the metric name, you might want to copy the metric name into a normal label as the very first step. Currently this is not possible withlabel_replace()for any functions that expect a range vector, aslabel_replace()only supports relabeling an instant vector.While you can do:
...the following is currently illegal:
But you would need this if you wanted to pass the result into a function that requires a range vector, as you can't specify a range selector (
[1m]) after arbitrary expressions, only basic series selectors.It's unclear to me though whether we want functions to take varying argument types, or how we would solve that if not.