Grafana Custom plugin for datasource


I’m new to grafana, did anyone now how data source plugin works, how to set up them and then what they can do exactly when they are set upped?

Hi @nicolasdossantos248

I am not sure if I understand your question.

If you are asking how to install datasource plugins you can read about plugin management

If you are asking how to create your own datasource plugin you can start by following this guide and taking a look at our plugin examples


Sorry if I’m wasn’t clear, I will try to reexplain. I want to create a plugin for my data source plugin for my database postgre. But for this actually when I try I can’t connect my plugin with my database.

I hope it’s more clear now.


Hi @nicolasdossantos248 this is still not clear for me:

I want to create a plugin for my data source plugin

you can’t create a plugin for a plugin. If you want to create a custom plugin you should follow the guides and examples I posted before. you can contribute to other plugins with your own modifications opening a PR in their git repositories (usually github).


I want to recreate a plugin for PostgreSQL like this I can modify the query builder. But all the guides i found don/t explain how to achieve the connection to the database.


Hi @nicolasdossantos248 what you want to read is about the query method. There’s a section dedicated to it here Build a data source plugin | Grafana Labs . The query method is what “connects” the plugin to a database. I advice you to read all this guide to have an idea of how grafana plugins work.

You can think of a datasource plugin as a computer “driver”. A piece of software that takes input from the user (e.g. SQL, date range) and outputs the data in a way grafana can understand.

You also need to instantiate (add) your datasource plugin to use it (in the grafana datasources admin page → add datasource). This is so the plugin know where the database is (url for example) and the auth data required to access it (admin, password, certificates, etc…)

The plugin itself needs to be programmed to handle the authentication, the communication and the user queries (that’s where the query method is important).

Finally, there are also datasource plugins that are written in go and run in the backend of grafana. They are essentially the same but benefit from running in the server and not in the user browser where they can have a wider variety of tools and resources to use.

You can find examples of all these types of datasources in our examples repository GitHub - grafana/grafana-plugin-examples