In Prometheus sometimes we need to plot several metrics at onces (say, having name, fitting the same regex) like that PromQL query:
{name=~"camel_proxy.*count"}
and it works fine, the same labelset lines are plotted with the different names.
When we want to plot the rate() of them, we face the error from the title:
rate({name=~"camel_proxy.*count"}[5m])
So, the way here is to make labelset not the same, and to move the __name__
to some label, making each labelset to be unique:
rate(label_replace({name=~"camel_proxy.*count"},"name_label","$1","name", "(.+)")[5m])
But we are still getting the error like
1:90: parse error: ranges only allowed for vector selectors"
How to avoid it and plot the rates correctly?
__name__
instead ofname
in the query that Ilya shared here - both in the metric-selector at the start, and also in thelabel_replace
function as follows:label_replace({__name__=~"camel_proxy.*count"},"name_label","$1","__name__", "(.+)")
(I tried to update the question itself with an edit, but the edit-queue on Stack Overflow was full 😢)