Referencing a variable in a variable

I current’y have a variable defined as:
$app = collectd.app*
it returns the following: app1,app2,app3,app4

I’ve created another variable referencing $app like so:
$partner = collectd.$app.curl_json*
This returns nothing.

If I recreate $partner like so: $partner = collectd.app*.curl_json*
It returns: curl_json-partner1, curl_json-partner2,curl_json-partner3

Why does this not work when using the example of collectd.$app.curl_json*?

Thanks

Hi @brents,

What’s the other config parameters for $app? Did you select the “Include All option” checkbox? Does it work if you select app=All?

Hi adeverteuil.

I’ve attached screen shots to help answer your questions. Unfortunately this website is preventing me from putting a third screenshot which shows the expected results when I don’t use nested variables.

Creating the app variable:

Trying to use the app variable while creating a new variable:

This is what I should see if the variables are working correctly.

What version of Grafana are you running exactly?

Does it help if you specify the glob formatting option?

collectd.${app:glob}.curl*

Doc: https://grafana.com/docs/reference/templating/#advanced-formatting-options

If not, can you please check in the browser developer tools what query is sent to the backend? Unfortunately there is no Query Inspector in the variables form like the one in the panel query editor.

  1. Open the developer console in your browser.
  2. Click in the Query field and make an idempotent change (add a character and delete it).
  3. Click on the page background to remove the focus. This triggers a query/response.
  4. Look for the HTTP transaction in the console, inspect the Graphite query that was sent to the backend.

6.2.2

Quite interesting find. When I look at the URI with the $app variable in it:

Request URL: https://192.168.1.1/api/datasources/proxy/1/metrics/find?query=collectd.%7Bapp302_nc_us%7D.curl*

When I run the query without the $app and replace it with app302_nc_us:

Request URL: https://192.168.1.1/api/datasources/proxy/1/metrics/find?query=collectd.%7Bapp302_nc_us%7D.curl*

They are exactly the same yet producing two different results.

Glob, which I did try, had the same results. I’m not sure why it is set to use app302_nc_us vs all. Regardless same results.

Brent

Does it help if you select a different value in the app variable dropdown on the dashboard? Maybe app302_nc_us doesn’t have any children curl* values?

If the partner variable refers to $app, then $app in the query will be replaced with what is actually selected on the dashboard, in the value list format. https://graphite.readthedocs.io/en/latest/render_api.html#paths-and-wildcards

In the URL, we see that the variable substitution happens with the values list syntax, because %7B and %7D are { and }. The decoded query becomes:

collectd.{app302_nc_us}.curl*

I am skeptical that two identical requests can produce different results from the backend. Can I see more details about the request/response pairs?

Can you create a free Hosted Grafana instance on Grafana.com and create a use-case dashboard so we can look at it interactively?

We have a demonstration dashboard running Grafana 6.2.4 with nested Graphite query variables and the bug doesn’t happen there:
https://play.grafana.org/d/000000056/graphite-templated-nested?orgId=1

I sent you a PM in regards to a screen share.

We have 36 different app servers. 24 in 1 location and 12 in another. I’m concerned with the 24. The first app server is not used in a similar fashion as the other 23. My regex removes the first one. All 23 app servers have the exact same curl_json collectd calls. I’ve verified the data exists in Graphite. I’ve also verified by using the explore option (I do like this feature) that all 23 app servers have the data and grafana is able to plot it.

You’re asking to see more data regarding the request and response pairs. I think a screen share would be best.

TTT… Anyone who might is having similar issues?