Looking up a variable value from another variable?

I want to display information about Cromulators and Decromulators on my dashboard. Each Cromulator is associated with one and only one Decromulator. I have a query variable that gets a list of Cromulators in my environment. This variable appears as a dropdown selection on my dashboard.

Once the user selects a Cromulator, I want to display information about the selected Cromulator and its associated Decromulator. I created a custom variable to map Cromulators (which are named after fruits) to their respective Decromulators (which are named after car parts):

Apple : Carburetor, Banana : SparkPlug, Cantaloupe: BrakeLight, Durian: WaterPump

I’m stuck trying to look up the appropriate Decromulator from the selected Cromulator in an expression so that I can display Decromulator information for the selected Cromulator. I thought I could do this with the custom variable, using the Cromulators as the keys and the Decromulators as the values, but it appears that Grafana won’t let me get the value of a key/value pair in an expression.

Is there any easy way to do a key/value lookup using the value of one variable as the key that will return the mapped value from a second variable?

(For what it’s worth, ‘Cromulators’ and ‘Decromulators’ in my case are Dimensions in CloudWatch queries.)

Have you explored the documentation and online examples for creating chained variables?

I’m also having the same issue. I wanted to make chained variable nodes of clusters these variables are created from Dimension Values in Cloudwatch.

That is not a particularly helpful suggestion. The examples do not mention lookups in other variables (e.g. creating mappings for looking up human-readable labels for particular keys).

For example, if I had a list of metrics, and a mapping of metrics to human-readable labels, I thought I could do:

Avg. $metric_names[$metric] per Client

But this does not work.


did you solve this? I also wonder how to add a human description to the graph (or, to a variable selectbox itself), when I have influx measurements with tags like id=B3 desc="Main frobnicator in building B".

Also, InfluxDB documentation tends to prefer their shiny new Flux language, while most Grafana examples still use their older InfluxQL.

This seems to be an open feature request: https://github.com/grafana/grafana/issues/1032

Various alternative solutions have been proposed (e.g. when using Postgres as a datasource), but nothing native seems to exist here.