Templating and Value Mapping

Hey there,

I think this is more generally a Templating question, but my use case is for Singlestat Panel.

So I want to show a Singlestat Panel with title [[app_names]]. But I do not repeat the Panel over [[app_names]], but over [[app_ids]]. Yet, every app_id maps to only one app_name.

Can I iterate using Repeat Panel over [[app_ids]], but get a value of [[app_names]] for each Panel? How would I do this? Thanks

Hi! It’s impossible now to map values from one variable to another. You can try to solve your problem by using scripted dashboard, but it requires basic JS knowledge.

Hey Alexander,

Thanks for your response. I think scripted dashboards may be a solution for me, but I never figured out how to add a Prometheus Data Source to them. When I export a Grafana Dashboard to JSON, it includes a line like this:

"__inputs": [ { "name": "DS_PROMETHEUS", "label": Prometheus", ... } ]

However, if I create a dashboard using this JSON in mydashboard.js, it gives me an error like

Templating init failed Datasource named ${DS_PROMETHEUS} was not found

Do you happen to know how I can resolve this? I thought that exporting JSON and then just re-using the JSON should work, as a sanity check.

You can use data source name like
"datasource": "Prometheus"
without "__inputs":