grafana/grafana-plugin-examples

Example: how to implement template variable support in data source

mckn opened this issue · 3 comments

mckn commented

The available method on the datasource plugin class is marked as deprecated. Without any examples or documentation on alternative approaches. We should provide some examples covering the different ways of adding a template variable support to data sources.

This is how you add the variable support to the data source:
https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/grafana-testdata-datasource/datasource.ts#L37

This is an example of how you implement the standard variable support:
https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/grafana-testdata-datasource/variables.ts

StandardVariableSupport = Extend this class in a data source plugin to use the standard query editor for Query variables
CustomVariableSupport = Extend this class in a data source plugin to use a customized query editor for Query variables
DataSourceVariableSupport = Extend this class in a data source plugin to use the query editor in the data source plugin for Query variables

mckn commented

We already have this one in the grafana/grafana repository grafana/grafana#63619

Do we have an example coming from a class with DataSourceWithBackend ?

mckn commented

No, I don't think we have any example. We should add one to this repository before closing this issue.