4

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

2 Answers 2

2

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?

Sign up to request clarification or add additional context in comments.

1 Comment

That was my first approach, because the data source (http request) has a parameter for clients, but only in the ip address format. I configured the variable to show the hostnames in the dropbox so users can identify the host based on the FQDN. I think I have to focus on the variable end to make sure I have an IP Address and find a workaround for the user to see the hostname.
2

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: enter image description here

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.