How to lookup value based on dynamic dashboard variable value?

Grafana version (v10.4.0) Dashboard panels rows repeated with variable value from system1 (AppDynamics Tiers) and another system have different naming(AWS CloudWatch service name), so we need a lookup based on system1 variable value to another system name.

Trying with Dashboard variable with key value pair. but it work by value selection manually but required with repeating option and set dynamic lookup value without manual selection.

Repeating variable: $v_appd_app_tiers (example: system1_value0, system1_value1…etc)
Lookup variable: $v_aws_cw_servicename
Example: system1_value0 : system2_value0,system1_value1 : system2_value1
Expected output: get value of system2_value0 (value) by system1_value0 (key) using variable value $v_appd_app_tiers dynamically

Can you please help me how to achieve this?

Create “mapping table” in your favorite SQL engine, e.g.:

v_appd_app_tiers v_aws_cw_servicename
system1_value0 system2_value0
system1_value1 system2_value1

Create datasource for that SQL engine in the Grafana and create dynamic lookup variable v_aws_cw_servicename as SQL query:

SELECT v_aws_cw_servicename
FROM "mapping table"
WHERE v_appd_app_tiers='$v_appd_app_tiers'

This is not copy&paste solution, just quick idea for demonstration how to do that - fix any syntax issues, naming conventions, … and improve it for your case. It can be more complicated if you need multivalue/all support, etc.

1 Like

Thank you for the details. It will be more helpful if Grafana provide mapping options with in the tool instead depending on another source.

Ok, but then it will be very complex if you want to cover everything: multivalues, regexp,… and users will be complainining about complexity, missing features, etc. SQL is very mature language, so I don’t see a reason to reinvent a wheel. You can use existing datasource if you can implement that business logic there.

1 Like

Thank you, If $v_appd_app_tiers is repeated with rows. how do we pass $v_appd_app_tiers value to SQL query.