Implementation of Template Variables in a Frontend Datasource Plugin

Hi Grafana Team,

I am currently working on a frontend datasource plugin and need guidance on implementing template variables. Is it possible to support the template variable feature without a backend plugin? If so, could you provide some insights or best practices on how to effectively integrate template variables into a frontend datasource plugin? Specifically, I would like to know:

  1. The correct way to reference and use template variables within the plugin.
  2. How to handle variable changes and updates dynamically.
  3. Any common pitfalls or considerations to keep in mind during implementation.

Thank you for your assistance!
Regards,
Sarath S R

Hi.

Take a look at our documentation about template variables it should have all the answers Add support for variables | Grafana Plugin Tools

Is it possible to support the template variable feature without a backend plugin?

@sarathsr yes. Please see the documentation I linked it is all typescript code. There’s no backend code involved.

what about doing the same in backend plugin? I want to add template variable feature for my backend datasource plugin

You need to implement the interpolation logic in the frontend too. but if you are using DataSourceWithBackend this should be already handled for you unless you overwrite the query method from that class.