How to use variables or values to dynamically change background image in Canvas?

I’m trying to change the background of the canvas dynamically based on the value of a variable or a metric… I know that there is a field to put the value from a query, but the results are numeric, right? I tried some stuff, but none of them seems to be working…
For example, whether I select city=Curitiba on the dashboard variable or the metric comer with city=Curitiba, I want the background to change based on that
How can I do it?

The metrics does exists (checked on explore)
Using Pushgateway 1.6.0, Prometheus 2.46.0, Grafana 10.1.5, all via Docker in a Ubuntu 22.04.3, browsing with Firefox 118.0.2 64-bit

I have the same question, I use a field with the URL to the background image which changes depending on sunset/sunrise. When I use the ‘field’ option for the background, the URL is not loaded unfortunately, I assume the field option is just for a single color (or color code), right? When I use the ‘fixed’ option with the URL mode, the background image is loaded as desired. Is there a way of dynamic changing the background image?

Many thanks and Cheers,


This is what I got from the Community Bot:
"Currently, the Canvas panel in Grafana does not have built-in support for dynamically changing the background image based on data or variables. The background image is typically set as a static URL in the panel configuration.

However, you can achieve a similar effect by using other Grafana features and plugins in combination with the Canvas panel. Here are a couple of approaches you can consider:

Use a variable and conditional formatting: You can create a variable in Grafana that represents the background image URL. Then, use conditional formatting in the Canvas panel to change the appearance of elements based on the selected variable value. For example, you can have different elements or layers in the Canvas panel with different background images, and show/hide them based on the selected variable value.

Utilize a custom plugin: If the built-in functionality of the Canvas panel doesn't meet your requirements, you can explore custom plugins for Grafana. There might be third-party plugins available that provide more advanced features, including dynamic background image support. You can search the Grafana plugin repository or explore external plugin sources to find a suitable plugin that fits your needs.

Remember to thoroughly evaluate and test any third-party plugins before using them in a production environment, as they may have varying levels of stability and support.

Please note that the availability and compatibility of plugins may vary, so it’s recommended to check the documentation and compatibility of any plugins you consider using."