Need to set variable in same dashboard when clicking a cell in a table

  • I’m on Grafana 9.4.7 on Windows

  • I am trying to update a variable on a dashboard called test_name with the value of a cell in a table when that cell in the table is clicked.

  • Right now I have a data link set in overrides that looks like this:

  • I have tried several URLs to try and update the test_name variable and can’t seem to get anything to work. The variable is listed at the top of the dashboard like this:
    image

Am I taking the right approach? Basically, I want this:

what purpose will that text field that should be populated the the click value serve? Will it be used for something else to be filtered?

The value of the Test Name variable is used in another panel. That part is working fine. If I copy and paste the value from the table into the Test Name variable it works exactly how I want, I just want to make it so we don’t have to copy paste and clicking on the test name in the table as shown above populates the test name variable.

You might want to look at data link. That way you might not even need that text field at all. The other panel can pick up the value of the clicked row and use it to display details for test clicked

1 Like

OK, I have looked at data link. How does one fill out a data link to get this working? I’ve tried several things and nothing seems to work.

That said, I still want the field. I don’t want to just have the value be something that displays in some read-only capacity. I want people to be able to paste in a test name that is unrelated to this list if they want to.

1 Like

you do something like this:
the address to the desired dashboard, and variables added like this: &var-varName1=${__value.text}, This will be referencing the value of the cell.

image

3 Likes

@fercasjr that worked great, except that it is now overwriting the values for the other variables since I just basically copied their values when I copied that dashboard url. And if I remove the variables from the url they also change (maybe to defaults?). Is there a way to keep those variables the same as they currently are somehow? To preserve their values when updating the test variable?

well for me it usually works but I have my other variables populated from a query that uses the “main variable” so if I click the link var1 is updated and all the other variables reference var 1 so it cascades.

Also, it is possible pull more data from your table to populate the other variables, but that depends on your particular use case.
I don’t know if this would help you but i.e. My the table has also a field (column) named “_runtime” that I use in the URL as a variable like: ${__data.fields._runtime}

OK I actually got things working by doing this for the other variables, just replacing varname with the variable name you want to insert in the url.:

${varname:queryparam}

You just put that in the url for any variable you want to keep the same and it preserves it in its current state.

3 Likes

true hero

Hello,

Just to add more information in case someone else is experiencing similar issues: if you need to maintain your variables as they were before clicking the link, you can use ${__all_variables}. If you want to overwrite the variable instead of adding the selection clicked, use ${__all_variables_except_varName}.