How did grafana front end figure out all the available values in those template variables?

image

See this picture, there are 3 available values for the variable “Datasource”.
Prometheus, default, and Prometheus-envoy.

I am trying to build some programmatic UI tool around grafana, but I couldn’t figure out how these 3 values are loaded dynamically. Is it rendered by the server directly? But the initial HTML doesn’t contain those values at all. I couldn’t find any APIs that returned those values either.

Hi!

It looks like you have a data source variable. Have a look at the documentation https://grafana.com/docs/grafana/latest/variables/templates-and-variables/. If you want to know more about how they are implemented, feel free to take a look at the source code on Github :slight_smile:

/Tobias Skarhed