Reputation: 123
I tried to use the “Filter data by value” from the “Transformation types and options” in my table. I’d like to match the data against a variable (in this case the hostname) the user has selected via a dropdown box.
Unfortunately this does not work. Entering the value for the host directly as a string works. What is the notation here? $Host, ${Host}?
Or is it not allowed to use variables here?
thanks Andi
Upvotes: 4
Views: 14479
Reputation: 623
I landed here because I wanted to use variables in the "Filter data by value" transformation in Grafana.
Looks like it is still not supported as of today (see feature request), but depending on what you want to do exactly and which data source you use, you might be able to achieve the same in the query (which didn't work for the Andi, who posted the question, as far as I understood - but maybe it helps someone else):
E.g., I use InfluxDB and had this query:
I wanted to display only "z_amp" values where the "freq" field matches the $freq variable. I converted the query into text and added 'AND "freq"=${freq}' to the end:
SELECT "z_amp", "freq" FROM "xyz_data" WHERE ("slave_id" =~ /^$slave_id$/ AND "slave_xyz" =~ /^$xyz_id$/ AND "op_cond" =~ /^$op_cond$/ AND "xyz_valid" =~ /^$is_valid$/) AND $timeFilter AND "freq"=${freq}
Using a "Filter by name" transformation, I can hide the freq field again, so only the matching z_amp values are shown.
Upvotes: 2
Reputation: 22321
You can't use variables in the value field.
Have you tried to filter the host (set by this variable) in the query tab instead?
Upvotes: 2