grafana-backuper/main.go
Tom Neuber 2d08f75545
All checks were successful
continuous-integration/drone/push Build is passing
add grafana package & temporary debug checks
2024-02-15 10:56:18 +01:00

42 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)
}
}
}