weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.86k stars 309 forks source link

Allow importing a dashboard JSON into grafanalib (for further customization)? #608

Open fzyzcjy opened 1 year ago

fzyzcjy commented 1 year ago

As we all know, there are a ton of dashboards in https://grafana.com/grafana/dashboards/, and it saves a lot of time to import it (and do some customization). However, currently I find it hard to convert that JSON into a python file using grafanalib.

YAMLcase commented 1 year ago

Here's my nightmare use case: I've been handed the task of writing Alert Rules for each of our useful dashboard panels (there are thousands). One thing I overlooked while scoping this project is there's no way to programmatically do this in grafana. And since we're pretty good about dynamically building dashboards with template variables we can't even do it by visiting each panel and creating the alert there.

grafanalib seems like the natural choice for pulling in a dashboard then writing an alert rule around it.

fzyzcjy commented 1 year ago

@YAMLcase I have built a small library which supports this feature (JSON -> python), maybe you can have a try? https://github.com/fzyzcjy/grafana_dashboard_python

amotl commented 4 months ago

Hi. We are currently modernizing grafana-import by @peekjef72, adding relevant features to support dashboard-as-code workflows. It also supports grafana-dashboard by @fzyzcjy, thank you so much!

Let us know about any kinds of ideas and suggestions you may have on this matter.

-- https://community.grafana.com/t/backing-up-or-committing-dashboards-to-github/26194/9