Convert queries into one line queries and escape all commas , with backslash \. All commas in queries must be escaped beacuse comma is used in Custom variable to separate different queries (i.e. CPU, MEM). E.g. my queries would become:
2. Add dashboard variable of type Custom (Settins → Variables → New variable). Under Custom options add all one line formated queries (i.e. CPU and MEM) and separate queries with comma ,. You can also add labels that will show in drop-down instead of raw query e.g. CPU and MEM. So, final query that you should add in Custom options would look like:
If you found dynamic queries useful please support Grafana feature request that would allow usage of different delimiters, prefixes and suffixes for multi value variables. This would allow even better dynamic queries since you would be able to create queries with multi value variables. Feature request can be found on:
works fine if I just use it in a panel, but I need it to be selected by user…
Looks like Grafana doesn’t replace variable test_var with its value in this case and sends “${test_var}” to InfluxDB instead of “used_percent”
Hi @ebabeshko did you manage to find any solution for solving this issue? I’m facing exactly the same in my PromQL query now. Thanks
@ldrascic do you have any ideas? My problematic query is
label_replace(rate(hb_in_req_count{host=~“($Host)”}[1h]), “custom_legend”, “Metrics ($1)”, “host”, “(.*)”). When I set it as an option for variable - the “Host” is not being caught from another variable.
Is it possible to fix?
I had to hardcode values in queries instead of variables. So now user can choose queries, but none of them contains variables. Otherwise it didn’t work out.