Grafana 4.6 build process changes


I have noticed some changes in the build process when switching to Grafana 4.6 while developing my own datasource plugin.

When building the front-end part of grafana from sources, I usually run grunt or npm run build - this used to generate the public_gen directory where I could find my compiled datasource files. But with the recent version I do not see any public_gen dir.

Later when I start grafana, it displays an error when it tries to use my datasource plugin :

error: Fetch error: 404 Not Found Instantiating http://localhost:3000/public/app/plugins/datasource/my_datasource/module Loading app/plugins/datasource/my_datasource/module

Where there any changes to the build process (the grunt output definitely looks different)? And, is there something I need to change in my datasource plugin to be compliant to these latest updates?

I am testing this on the latest grafana sources (#2bc57d856c35864d407e7d20b587d56011f67fb5).

Thank you for any help!

Did you check building from source or github Readme? They contain updated build instructions

We switched to webpack, there is public gen anymore, built assets are in public build

I am running npm run build. This produces some .js files in public/build but nothing that would be related to my datasource plugin.

I am going through this commit :

And it looks like all plugins included in app/plugins/datasource are now hardcoded in the public/app/features/plugins/plugin_loader.ts.

I am wondering, what is now the official way add a custom datasource plugin and have it built/compile? Is there some other directory where I need to put my datasource plugin?

External plugins shout be in the external plugins folder /var/lib/grafana/plugins on installed systems or) data/plugins (relative to repo) on dev setups.

Plugins need their own build setup.

The placement of plugins is not new it has always been the case, we have never recommended you place your own plugins inside grafanas code base (data folder is git ignored so is never considered part of repo so your plugin will never be mixed up it grafana code)

Well, most of the 3rd party datasource plugins and related documentation was lagging behind the latest grafana version and even the example-datasource plugin was not compiling at the time when we started with our own plugins (~6months ago).
So, it was easier to look at official datasource plugins and mimic their design. That got us up and running quickly while benefiting from the existing build system.

I will look into setting up a separate build/release pipeline for the plugin then. Thanks!

yes, I know the docs around plugin development has been poor (and rarely updated).

For data sources we have a new example:

1 Like

Thanks! This is new!

Following this I was able to migrate my plugin to a separate build system, thank you!