K-Phoen / grabana

User-friendly Go library for building Grafana dashboards
MIT License
680 stars 69 forks source link

Dump dashboard as json #258

Closed varac closed 5 months ago

varac commented 5 months ago

Is there already an option to dump the generated dashboard as JSON ? If so it would be great to have this documented, I couldn't find it so far.

K-Phoen commented 5 months ago

You can use Go's json.Marshal() :)

builder, err := dashboard.New(
    "Awesome dashboard",
    // ...
)
if err != nil {
    // ...
}

dashboardJSON, err := json.Marshal(builder)
if err != nil {
    // ...
}