grafana-wizzy / wizzy

Manage & automate Grafana with easy wizzy
https://grafana-wizzy.com
Apache License 2.0
468 stars 60 forks source link

PoC: Add support for templating #148

Open johnsudaar opened 5 years ago

johnsudaar commented 5 years ago

This is a basic support for templating in wizzy. Adding it ad the fs part make it really easy and makes templating available for every wizzy resources.

The templating engine used is handlebars: http://handlebarsjs.com/

johnsudaar commented 5 years ago

Small demo: https://streamable.com/7lghf

Sytten commented 5 years ago

That is very nice! I feel like the original author is not maintaining the lib anymore. I think it would be worth forking or asking him to have a new maintainer. How does it work if you import changes from the remote? I guess it would override it right? Also I think it would be better if we could import those parameters from a configuration that could be set per environment.

johnsudaar commented 5 years ago

Thanks. Yeah importing a dashboard would override the hbs file back to the raw json. I don't see any workarround for that.

Good idea having a way to store those variables in a file can be cool. Maybe in wizzy/config.js we could use a variable entry that could be set globally and per context?

Sytten commented 5 years ago

Yeah that's what I feared (for import), maybe a good first step would be to warn the user if he overrides a template? It would be nice to be able to be able to modify a dashboard in grafana and still be able to import the diff.

I am not sure I would put it all in config.js. It could be use for sensitive variables, but it would also be nice to have another file for non-sensitive variables that could be commited.

utkarshcmu commented 5 years ago

Feel free to merge this PR guys, you both have the ability to merge the PRs to the project. I will work on the Release and Org side so that you guys have more control on this project.

johnsudaar commented 5 years ago

Detecting if the template has been modified by the user or if the remote had changed is not an easy task.

We could add the templating engine only if the file has a particular extension (like: .json.tmpl) and warn the user if he tries to import a dashboard that has a template file.

Sytten commented 5 years ago

Do you plan to finish the feature and add tests for it? It would be nice to have the feature land in 0.8.0.

johnsudaar commented 4 years ago

Hi there Sorry for the long time there, i had other things that took priority ...

What does this PR miss to be merged ?

Sytten commented 4 years ago

Heee let me review it, I am also super busy