add grafana package & temporary debug checks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tom Neuber 2024-02-15 01:12:57 +01:00
parent 1247fc3fcb
commit 2d08f75545
Signed by: tom
GPG key ID: F17EFE4272D89FF6
9 changed files with 373 additions and 0 deletions

42
main.go Normal file
View file

@ -0,0 +1,42 @@
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)
}
}
}