How to add a prefix to a query variable value?

I have a query variable in a dashboard.

My query returns the values of the label “span_kind”:


However, what I need it to add a prefix “APPLICATION” to all values. For instance:


I tried using regex, but it seems it can only filter, but not replace.

Thanks in advance

If there are not a lot of values, you could try a value mapping:

Hi @sowdenraymond thanks for your response!

However I don’t think I can use value mapping, because from what I understand it only changes the way data is presented.

In my case I need to change the variable value to be used in a query.

I should have given more details sorry for that:
What I’m really trying to do is to have a variable that has two values: A and B

When the user selects A, I have a dashboard that must use the following query:


When the user selects B, the query must change to:

duration_count{service_name="my_service", span_kind="SPAN_KIND_SERVER"}

So a change of the variable must change the metric from http_server_duration_count to duration_count, AND also add the label filter: span_kind=“SPAN_KIND_SERVER”

Changing the metric name is pretty straightforward, but I’m struggling to also add the label filter

Any idea is appreciated

How did you implement it and why it can’t be used also for that label filter?

Here’s how I implement it for changing the metric name:

1-Set up my variable named “metric_name” as “custom” with 2 possible values: http_server_duration, duration

2-Use my variable on the PromQL queries on my dashboard:


What I could’nt do, and dont know if its possible, is that when I select the option “duration”, I would also like to change the query to filter by {span_kind=“SPAN_KIND_SERVER”}, like:


I guess I could add a second variable, with 2 values (one empty value and one {span_kind=“SPAN_KIND_SERVER”} value) but ideally I want to control this with a single variable

Well from what I can gather, it’s not possible to add a prefix or sufix to the value of a query variable.
I ended up changing my query to accept both a empty span_kind, or a span_kind=“SPAN_KIND_SERVER”, like this


The | is an regex OR so the span_kind can be either empty or SPAN_KIND_SERVER


This solved my issue