{"id":13582165,"url":"https://github.com/K-Phoen/grabana","last_synced_at":"2025-04-06T14:30:28.270Z","repository":{"id":37011765,"uuid":"237280568","full_name":"K-Phoen/grabana","owner":"K-Phoen","description":"User-friendly Go library for building Grafana dashboards","archived":false,"fork":false,"pushed_at":"2024-08-02T13:33:58.000Z","size":3060,"stargazers_count":709,"open_issues_count":34,"forks_count":73,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T00:36:31.317Z","etag":null,"topics":["builder","dashboard-configuration","dashboards","golang","grafana","grafana-dashboard","grafana-dashboards","hacktoberfest","library","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/K-Phoen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["K-Phoen"],"patreon":"kevin_gomez","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-01-30T18:43:13.000Z","updated_at":"2025-03-26T18:49:12.000Z","dependencies_parsed_at":"2022-07-11T15:03:32.393Z","dependency_job_id":"838ae622-76d9-4b6c-ba60-7807dc35e8c3","html_url":"https://github.com/K-Phoen/grabana","commit_stats":{"total_commits":443,"total_committers":16,"mean_commits":27.6875,"dds":"0.30925507900677196","last_synced_commit":"bb1093ebf576342853936e8663900c30aff48336"},"previous_names":[],"tags_count":107,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Phoen%2Fgrabana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Phoen%2Fgrabana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Phoen%2Fgrabana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Phoen%2Fgrabana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K-Phoen","download_url":"https://codeload.github.com/K-Phoen/grabana/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247495610,"owners_count":20948084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder","dashboard-configuration","dashboards","golang","grafana","grafana-dashboard","grafana-dashboards","hacktoberfest","library","yaml"],"created_at":"2024-08-01T15:02:28.010Z","updated_at":"2025-04-06T14:30:27.920Z","avatar_url":"https://github.com/K-Phoen.png","language":"Go","funding_links":["https://github.com/sponsors/K-Phoen","https://patreon.com/kevin_gomez"],"categories":["开源类库","Monitoring","Go","Open source library","Kubernetes"],"sub_categories":["监控告警","Grafana","Monitoring","Kubernetes // Grafana"],"readme":"# Grabana\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/K-Phoen/grabana)](https://goreportcard.com/report/github.com/K-Phoen/grabana) ![CI](https://github.com/K-Phoen/grabana/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/K-Phoen/grabana/branch/master/graph/badge.svg)](https://codecov.io/gh/K-Phoen/grabana) [![GoDoc](https://godoc.org/github.com/K-Phoen/grabana?status.svg)](https://godoc.org/github.com/K-Phoen/grabana)\n\nGrabana provides a developer-friendly way of creating Grafana dashboards.\n\nWhether you prefer writing **code or YAML**, if you are looking for a way to\nversion your dashboards configuration or automate tedious and error-prone\ncreation of dashboards, this library is meant for you.\n\n## Design goals\n\n* provide an understandable abstraction over dashboards configuration\n* expose a **developer-friendly API**\n* allow IDE assistance and **auto-completion**\n* **generate Go code** from existing dashboards\n\n**Note**: Grafana 8+ is required, with [unified alerting](https://grafana.com/blog/2021/06/14/the-new-unified-alerting-system-for-grafana-everything-you-need-to-know/) enabled.\n\n## See also\n\n* [`grafana-foundation-sdk`](https://github.com/grafana/grafana-foundation-sdk): A set of tools, types and libraries for building and manipulating Grafana objects – built by Grafana Labs\n* [`dark`](https://github.com/K-Phoen/dark): (grafana) Dashboards As Resources in Kubernetes\n\n## Dashboard as code\n\nDashboard configuration:\n\n```go\nbuilder := dashboard.New(\n    \"Awesome dashboard\",\n    dashboard.AutoRefresh(\"5s\"),\n    dashboard.Tags([]string{\"generated\"}),\n    dashboard.VariableAsInterval(\n        \"interval\",\n        interval.Values([]string{\"30s\", \"1m\", \"5m\", \"10m\", \"30m\", \"1h\", \"6h\", \"12h\"}),\n    ),\n    dashboard.Row(\n        \"Prometheus\",\n        row.WithGraph(\n            \"HTTP Rate\",\n            graph.DataSource(\"prometheus-default\"),\n            graph.WithPrometheusTarget(\n                \"rate(prometheus_http_requests_total[30s])\",\n                prometheus.Legend(\"{{handler}} - {{ code }}\"),\n            ),\n        ),\n    ),\n)\n```\n\n\u003e **Note**\n\u003e Existing dashboards can be converted to Go code using the `grabana convert-go` CLI command.\n\nDashboard creation:\n\n```go\nctx := context.Background()\nclient := grabana.NewClient(\u0026http.Client{}, grafanaHost, grabana.WithAPIToken(\"such secret, much wow\"))\n\n// create the folder holding the dashboard for the service\nfolder, err := client.FindOrCreateFolder(ctx, \"Test Folder\")\nif err != nil {\n    fmt.Printf(\"Could not find or create folder: %s\\n\", err)\n    os.Exit(1)\n}\n\nif _, err := client.UpsertDashboard(ctx, folder, builder); err != nil {\n    fmt.Printf(\"Could not create dashboard: %s\\n\", err)\n    os.Exit(1)\n}\n```\n\nFor a more complete example, see the [`example`](cmd/builder-example/) directory.\n\n## Dashboard as YAML\n\nDashboard configuration:\n\n```yaml\n# dashboard.yaml\ntitle: Awesome dashboard\n\neditable: true\ntags: [generated]\nauto_refresh: 5s\n\nvariables:\n  - interval:\n      name: interval\n      label: Interval\n      values: [\"30s\", \"1m\", \"5m\", \"10m\", \"30m\", \"1h\", \"6h\", \"12h\"]\n\nrows:\n  - name: Prometheus\n    panels:\n      - graph:\n          title: HTTP Rate\n          height: 400px\n          datasource: prometheus-default\n          targets:\n            - prometheus:\n                query: \"rate(promhttp_metric_handler_requests_total[$interval])\"\n                legend: \"{{handler}} - {{ code }}\"\n```\n\nDashboard creation (or [automatically as a Kubernetes Resource, using DARK](https://github.com/K-Phoen/dark)):\n\n```go\ncontent, err := os.ReadFile(\"dashboard.yaml\")\nif err != nil {\n    fmt.Fprintf(os.Stderr, \"Could not read file: %s\\n\", err)\n    os.Exit(1)\n}\n\ndashboard, err := decoder.UnmarshalYAML(bytes.NewBuffer(content))\nif err != nil {\n    fmt.Fprintf(os.Stderr, \"Could not parse file: %s\\n\", err)\n    os.Exit(1)\n}\n\nctx := context.Background()\nclient := grabana.NewClient(\u0026http.Client{}, grafanaHost, grabana.WithAPIToken(\"such secret, much wow\"))\n\n// create the folder holding the dashboard for the service\nfolder, err := client.FindOrCreateFolder(ctx, \"Test Folder\")\nif err != nil {\n    fmt.Printf(\"Could not find or create folder: %s\\n\", err)\n    os.Exit(1)\n}\n\nif _, err := client.UpsertDashboard(ctx, folder, dashboard); err != nil {\n    fmt.Printf(\"Could not create dashboard: %s\\n\", err)\n    os.Exit(1)\n}\n```\n\n## Going further\n\nCheck out [the documentation](doc/index.md) to discover what Grabana can do for\nyou.\n\n\n## License\n\nThis library is under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FK-Phoen%2Fgrabana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FK-Phoen%2Fgrabana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FK-Phoen%2Fgrabana/lists"}