grafanalib icon indicating copy to clipboard operation
grafanalib copied to clipboard

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

Open fzyzcjy opened this issue 2 years ago • 3 comments

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.

fzyzcjy avatar Jul 11 '23 02:07 fzyzcjy

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.

YAMLcase avatar Jul 12 '23 21:07 YAMLcase

@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

fzyzcjy avatar Jul 12 '23 23:07 fzyzcjy

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

amotl avatar Apr 27 '24 14:04 amotl