{"id":13560730,"url":"https://github.com/FUSAKLA/autograf","last_synced_at":"2025-04-03T16:31:02.438Z","repository":{"id":44447647,"uuid":"512567704","full_name":"FUSAKLA/autograf","owner":"FUSAKLA","description":"Dynamically generate Grafana dashboard based on Prometheus metrics","archived":false,"fork":false,"pushed_at":"2023-10-31T21:17:10.000Z","size":563,"stargazers_count":145,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-22T18:44:17.033Z","etag":null,"topics":["automation","command-line-tool","dashboard","grafana","monitoring","observability","prometheus"],"latest_commit_sha":null,"homepage":"https://github.com/FUSAKLA/autograf#readme","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FUSAKLA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-07-11T00:12:02.000Z","updated_at":"2025-02-25T17:26:21.000Z","dependencies_parsed_at":"2023-10-31T22:23:53.600Z","dependency_job_id":null,"html_url":"https://github.com/FUSAKLA/autograf","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FUSAKLA%2Fautograf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FUSAKLA%2Fautograf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FUSAKLA%2Fautograf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FUSAKLA%2Fautograf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FUSAKLA","download_url":"https://codeload.github.com/FUSAKLA/autograf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247036938,"owners_count":20873054,"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":["automation","command-line-tool","dashboard","grafana","monitoring","observability","prometheus"],"created_at":"2024-08-01T13:00:49.045Z","updated_at":"2025-04-03T16:31:02.061Z","avatar_url":"https://github.com/FUSAKLA.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Autograf\n[![Go Report\nCard](https://goreportcard.com/badge/github.com/fusakla/autograf)](https://goreportcard.com/report/github.com/fusakla/autograf)\n[![GitHub actions\nCI](https://img.shields.io/github/actions/workflow/status/fusakla/autograf/go.yaml)](https://github.com/fusakla/autograf/actions?query=branch%3Amain)\n[![Docker Pulls](https://img.shields.io/docker/pulls/fusakla/autograf)](https://hub.docker.com/r/fusakla/autograf)\n[![GitHub binaries\ndownload](https://img.shields.io/github/downloads/fusakla/autograf/total?label=Prebuilt%20binaries%20downloads)](https://github.com/fusakla/autograf/releases/latest)\n\n**Dynamically generate Grafana dashboard based on Prometheus metrics**\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./autograf.excalidraw.png\"\u003e\u003c/p\u003e\n\nHave you ever needed to debug issues and ended up querying Prometheus for `group({app=\"foo\"}) by (__name__)` to find out\nwhat metrics the app exposes and than querying all of them fo find anything suspicious? Or do you often encounter apps\nthat do not have any official dashboard?\n\n_Well I have a good news for you, Autograf have you covered!_ :tada:\n\n## How does it work?\nAutograf generates Grafana dashboard directly from `/metrics` or based on a metrics matching provided selector. Each\nmetric has own panel optimized for its type and those are grouped based on metric namespacing. If you want Autograf can\neven upload the dashboard right your to a Grafana for you!\n\n[autograf-2.webm](https://user-images.githubusercontent.com/6112562/178546235-7f9f815d-e843-4b0c-84dc-4fba2270eedc.webm)\n\n## Installation\nUsing [prebuilt binaries](https://github.com/fusakla/autograf/releases/latest), [Docker\nimage](https://hub.docker.com/r/fusakla/autograf) of build it yourself.\n\n```bash\ngo install github.com/fusakla/autograf@latest\n```\nor\n```bash\nmake build\n```\n\n## Example\nTo see Autograf in action you can use the [demo example](./examples/demo/README.md). It is a simple docker-compose\nthat starts up Prometheus, Node exporter and Grafana. The Grafana instance is pre-configured with a datasource\npointing to the Proemtheus and service account. There is also an autograf.json config preset to test it with the setup.\nSee it's README for more details.\n\n## How to use?\n\n```bash\n./autograf --help\nUsage: autograf\n\nAutograf generates Grafana dashboard from Prometheus metrics either read from a /metrics endpoint or queried from live Prometheus instance. The dashboard JSON is by default printed to stdout. But can also upload the dashboard directly to\nyour Grafana instance. You can configure most of the flags using config file. See the docs.\n\nExample from /metrics:\n\n    curl http://foo.bar/metrics | autograf --metrics-file -\n\nExample from Prometheus query:\n\n    GRAFANA_TOKEN=xxx autograf --prometheus-url http://prometheus.foo --selector '{app=\"foo\"}' --grafana-url http://grafana.bar\n\nFlags:\n  -h, --help                                       Show context-sensitive help.\n      --debug                                      Enable debug logging\n      --version                                    Print Autograf version and exit\n  -i, --ignore-config                              Ignore any config file\n  -f, --metrics-file=STRING                        File containing the metrics exposed by app (will read stdin if se to - )\n      --open-metrics-format                        Metrics data are in the application/openmetrics-text format.\n  -p, --prometheus-url=STRING                      URL of Prometheus instance to fetch the metrics from.\n      --prometheus-bearer-token=STRING             Bearer token to use for authentication with Prometheus instance.\n  -s, --selector=STRING                            Selector to filter metrics from the Prometheus instance.\n      --grafana-variables=GRAFANA-VARIABLES,...    Labels used as a variables for filtering in dashboard\n      --grafana-url=STRING                         URL of Grafana to upload the dashboard to, if not specified, dashboard JSON is printed to stdout\n      --grafana-folder=STRING                      Name of target Grafana folder\n      --grafana-dashboard-name=STRING              Name of the Grafana dashboard\n      --grafana-data-source=STRING                 Name of the Grafana datasource to use\n      --open-browser                               Open the Grafana dashboard automatically in browser\n```\n\n### Loading data from all metrics exposed by app\n```bash\ncurl -q http://demo.robustperception.io:9090/metrics | ./autograf --metrics-file -\n```\n\n### Loading data from live Prometheus instance\nPrint Grafana dashboard JSON for all metrics matching selector `{instance=\"demo.do.prometheus.io:9090\",\njob=\"prometheus\"}` from the configured Prometheus instance.\n```bash\nautograf --prometheus-url http://demo.robustperception.io:9090 --selector '{instance=\"demo.do.prometheus.io:9090\", job=\"prometheus\"}'\n```\n\n### Uploading dashboard directly to Grafana\n```bash\nGRAFANA_TOKEN=\"xxx\" autograf --prometheus-url http://demo.robustperception.io:9090 --selector '{instance=\"demo.do.prometheus.io:9090\", job=\"prometheus\"}' --grafana-url https://foo.bar --grafana-folder test\nDashboard successfully generated, see https://grafana.foo.bar/d/ygUo8se7k/autograf-dashboard\n```\n\n## Config file\nIf you do not want to set all the flags again and again you can use a config file. By default autograf looks for it in\n`~/.autograf.json` and `~/.config/autograf.json` but can be changed using the `AUTOGRAF_CONFIG` env variable.\nSee the [example](./examples/demo/autograf.json) used in the demo.\n\n### Config file syntax\n```json\n{\n    \"prometheus_url\": \"http://demo.robustperception.io:9090\",\n    \"prometheus_bearer_token\": \"xxx\",\n\n    \"grafana_url\": \"https://grafana.foo.bar\",\n    \"grafana_dashboard_name\": \"Autograf\",\n    \"grafana_folder\": \"FUSAKLAS garbage\",\n    \"grafana_datasource\": \"Prometheus\",\n    \"grafana_token\": \"xxx\",\n    \n    \"open_browser\": true\n}\n```\n\nThan you can use simply just this!\n```bash\nautograf -s {job='foo'}\n```\n\n## Panel config customization (EXPERIMENTAL)\nThis feature allows you to customize how the panel will look like using the metric HELP text.\nTo use it include in the and of the metric HELP string ` AUTOGRAF:{...}` where the supported JSON options\ncan be found in the [`PanelConfig`](./packages/model/panel_config.go#L10). Example of such metric HELP can\nbe found in the [`./examples/metrics_custom.txt`](./examples/metrics_custom.txt).\n\n\n## Future ideas\n- **Autograf should actually be Grafana app plugin and user could just go to `https://grafana.foo.bar/autograf?selector={foo=\"bar\"}` and\n  the dashboard would show up right in the Grafana itself. Unfortunately my JS juju is not good enough for this.**\n- Add custom visuals for well known metrics.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFUSAKLA%2Fautograf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFUSAKLA%2Fautograf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFUSAKLA%2Fautograf/lists"}