43 lines
976 B
Go
43 lines
976 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
|
||
|
"git.ar21.de/yolokube/grafana-backuper/pkg/grafana"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
grafanaURL = "https://grafana.services.yolokube.de"
|
||
|
grafanaAPIKey = ""
|
||
|
gitRepoURL = ""
|
||
|
gitRepoDirectory = ""
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
ctx := context.Background()
|
||
|
client, err := grafana.NewClient(grafanaURL, grafanaAPIKey, grafana.DefaultHTTPClient)
|
||
|
if err != nil {
|
||
|
log.Fatalf("Error creating the grafana client: %v", err)
|
||
|
}
|
||
|
|
||
|
dashboards, err := client.SearchDashboards(ctx, "", false)
|
||
|
if err != nil {
|
||
|
log.Fatalf("Error fetching dashboards: %v", err)
|
||
|
}
|
||
|
|
||
|
for _, dashboard := range dashboards {
|
||
|
versions, err := client.GetDashboardVersionsByDashboardID(ctx, dashboard.ID)
|
||
|
if err != nil {
|
||
|
log.Fatalf("Error fetching versions for dashboard %s: %v", dashboard.Title, err)
|
||
|
}
|
||
|
|
||
|
fmt.Println(dashboard.Title)
|
||
|
fmt.Println(versions)
|
||
|
for _, version := range versions {
|
||
|
fmt.Printf("%s: %s\n", version.CreatedBy, version.Message)
|
||
|
}
|
||
|
}
|
||
|
}
|