Is there a way to add custom template variable type via plugin?

I’m using a custom Graphite plugin to pair my custom datasource with Grafana using Graphite API.

Recently I decided to try to add new template variable type to Grafana via my plugin, as “custom” type that looks like a dropdown list doesn’t 100% suit me, as it doesn’t keep current selection value in a text box if user clicks on it.

I’ve imported some functionality from ‘app/features/templating/variable’ to use in my plugin in exactly the same way as I import functionality from ‘app/plugins/sdk’. Typescript compilation is successful, but I face problems at runtime - it seems, that unlike with ‘app/plugins/sdk’, ‘app/features/templating/variable’ couldn’t be found and default index.html is imported instead:

# expected expression, got '<' Evaluating http://localhost:3000/public/app/features/templating/variable Evaluating http://localhost:3000/public/plugins/pktlogger-graphite/dropdown_variable.js Evaluating http://localhost:3000/public/plugins/pktlogger-graphite/module.js Loading plugins/pktlogger-graphite/module

The question is why I can import some functionality from the main Grafana tree into my plugin, but can’t import some other functionality? What are alternative ways to add customized variable type?

I’ve found the answer:


contains a list of modules that are exposed to plugins.

1 Like