{"id":13562144,"url":"https://github.com/IzakMarais/reporter","last_synced_at":"2025-04-03T18:32:38.342Z","repository":{"id":43019097,"uuid":"62891299","full_name":"IzakMarais/reporter","owner":"IzakMarais","description":"Service that generates a PDF report from a Grafana dashboard","archived":false,"fork":false,"pushed_at":"2022-08-24T06:58:54.000Z","size":8685,"stargazers_count":964,"open_issues_count":103,"forks_count":310,"subscribers_count":48,"default_branch":"master","last_synced_at":"2024-10-18T08:58:01.234Z","etag":null,"topics":["grafana","grafana-api","grafana-dashboard","grafana-reporter","pdf-report","reporting"],"latest_commit_sha":null,"homepage":"","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/IzakMarais.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-08T13:38:16.000Z","updated_at":"2024-10-10T11:28:55.000Z","dependencies_parsed_at":"2022-08-12T10:11:02.681Z","dependency_job_id":null,"html_url":"https://github.com/IzakMarais/reporter","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IzakMarais%2Freporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IzakMarais%2Freporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IzakMarais%2Freporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IzakMarais%2Freporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IzakMarais","download_url":"https://codeload.github.com/IzakMarais/reporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223010462,"owners_count":17072991,"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":["grafana","grafana-api","grafana-dashboard","grafana-reporter","pdf-report","reporting"],"created_at":"2024-08-01T13:01:05.111Z","updated_at":"2024-11-04T14:30:48.014Z","avatar_url":"https://github.com/IzakMarais.png","language":"Go","funding_links":[],"categories":["Go","others"],"sub_categories":[],"readme":"# Grafana reporter \u003cimg style=\"float: right;\" src=\"https://travis-ci.org/IzakMarais/reporter.svg?branch=master\"\u003e\n\nA simple http service that generates \\*.PDF reports from [Grafana](http://grafana.org/) dashboards.\n\n![demo](demo/report_v5.gif)\n\n## Requirements\n\nRuntime requirements\n\n- `pdflatex` installed and available in PATH.\n- a running Grafana instance that it can connect to. If you are using an old Grafana (version \u003c v5.0), see `Deprecated Endpoint` below.\n\nBuild requirements:\n\n- [golang](https://golang.org/)\n\n## Getting started\n\n### Build and run\n\nGet the source files and dependencies:\n\n    go get github.com/IzakMarais/reporter/...\n\nBuild and install `grafana-reporter` binary to `$GOPATH/bin`:\n\n    go install -v github.com/IzakMarais/reporter/cmd/grafana-reporter\n\nRunning without any flags assumes Grafana is reachable at `localhost:3000`:\n\n    grafana-reporter\n\nQuery available flags. Likely the only one you need to set is `-ip`. \n\n    grafana-reporter --help\n    -cmd_apiKey string\n          Grafana api key. Required (and only used) in command line mode.\n    -cmd_apiVersion string\n          Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5. (default \"v5\")\n    -cmd_dashboard string\n          Dashboard identifier. Required (and only used) in command line mode.\n    -cmd_enable\n          Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1).\n    -cmd_o string\n          Output file. Required (and only used) in command line mode. (default \"out.pdf\")\n    -cmd_template string\n          Specify a custom TeX template file. Only used in command line mode, but is optional even there.\n    -cmd_ts string\n          Time span. Required (and only used) in command line mode. (default \"from=now-3h\u0026to=now\")\n    -grid-layout\n          Enable grid layout (-grid-layout=1). Panel width and height will be calculated based off Grafana gridPos width and height.\n    -ip string\n          Grafana IP and port. (default \"localhost:3000\")\n    -port string\n          Port to serve on. (default \":8686\")\n    -proto string\n          Grafana Protocol. Change to 'https://' if Grafana is using https. Reporter will still serve http. (default \"http://\")\n    -ssl-check\n          Check the SSL issuer and validity. Set this to false if your Grafana serves https using an unverified, self-signed certificate. (default true)\n    -templates string\n          Directory for custom TeX templates. (default \"templates/\")\n\n\n### Generate a dashboard report\n\n#### Endpoint\n\nThe reporter serves a pdf report on the specified port at:\n\n    /api/v5/report/{dashboardUID}\n\nwhere `{dashboardUID}` is the dashboard uid as used in the Grafana dashboard's URL.\nE.g. `SoT6hL6zk` from `http://grafana-host:3000/d/SoT6hL6zk/descriptive-name`.\nFor more about this uid, see [the Grafana HTTP API](http://docs.grafana.org/http_api/dashboard/#identifier-id-vs-unique-identifier-uid).\n\n#### Deprecated Endpoint\n\nIn Grafana v5.0, the Grafana HTTP API for dashboards was changed. The reporter still works with the previous Grafana API too, but serves pdf reports at a different endpoint.\nSo, if you use Grafana v4, you need to download your reports from here instead:\n\n    /api/report/{dashboardname}\n\nwhere `{dashboardname}` is the same name as used in the Grafana v4 dashboard's URL.\nE.g. `backend-dashboard` from `http://grafana-host:3000/dashboard/db/backend-dashboard`.\nThis endpoint is deprecated and may be dropped in a future release of the grafana-reporter.\n\n#### Query parameters\n\nThe endpoint supports the following optional query parameters. These can be combined using standard\nURL query parameter syntax, eg:\n\n    /api/v5/report/{dashboardUID}?apitoken=12345\u0026var-host=devbox\n\n**Time span**: The time span query parameter syntax is the same as used by Grafana.\nWhen you create a link from Grafana, you can enable the _Time range_ forwarding check-box.\nThe link will render a dashboard with your current time range.  \nBy default, the time range will be included as the report sub-title. \nTimes are displayed using the reporter's host server time zone. \n\n\n**variables**: The template variable query parameter syntax is the same as used by Grafana.\nWhen you create a link from Grafana, you can enable the _Variable values_ forwarding check-box.\nThe link will render a dashboard with your current variable values.\n\n**apitoken**: A Grafana authentication api token. Use this if you have auth enabled on Grafana. \nSyntax: `apitoken={your-tokenstring}`. If you are getting `Got Status 401 Unauthorized, message: {\"message\":\"Unauthorized\"}`\nerror messages, typically it is because you forgot to set this parameter. \n\n**template**: Optionally specify a custom TeX template file.\nSyntax `template=templateName` implies the grafana-reporter should have access to a template file on the server at `templates/templateName.tex`.\nThe `templates` directory can be set with a command line parameter.\nSee the LaTeX code in `texTemplate.go` as an example of what variables are available and how to access them.\nAlso see [this issue](https://github.com/IzakMarais/reporter/issues/50) for an example. \n\n\n### Command line mode\n\nIf you prefer to generate a report directly from the command line without running a webserver,\ncommand line mode enables this. All flags related to command line mode are\nprefixed with `cmd_` to distinguish them from regular flags:\n\n    grafana-reporter -cmd_enable=1 -cmd_apiKey [api-key] -ip localhost:3000 -cmd_dashboard ITeTdN2mk -cmd_ts from=now-1y -cmd_o out.pdf\n\n### Docker examples (optional)\n\nA Docker image [is available](https://hub.docker.com/r/izakmarais/grafana-reporter/). To see available flags:\n\n    docker run izakmarais/grafana-reporter --help\n\nTo run with default flags, use `--net` to enable Docker to connect to Grafana at `localhost:3000`:\n\n    docker run -p 8686:8686 --net=\"host\" izakmarais/grafana-reporter\n\nIf you also have `Make` and `Docker-compose` installed, you can run a simple local orchestration of Grafana and Grafana-reporter:\n\n     go get github.com/IzakMarais/reporter/ ...\n     cd $GOPATH/src/github.com/IzakMarais/reporter\n     make compose-up\n\nThen open a browser to `http://localhost:3000` and create a new test dashboard. Add the example graph and save the dashboard.\nObserve the new URL and find the dashboard UID, e.g. `qaJCuCezz` from `http://localhost:3000/d/qaJCuCezz/new-dashboard-copy`\nNext, go to: `http://localhost:8080/api/v5/report/qaJCuCezz`, which will output the grafana-reporter PDF.\n\n## Development\n\n### Test\n\nThe unit tests can be run using the go tool:\n\n    go test -v github.com/IzakMarais/reporter/...\n\nor, the [GoConvey](http://goconvey.co/) webGUI:\n\n    ./bin/goconvey -workDir `pwd`/src/github.com/IzakMarais -excludedDirs `pwd`/src/github.com/IzakMarais/reporter/tmp/\n\n### Release\n\nA new release requires changes to the git tag, `cmd/grafana-reporter/version.go` and `Makefile: docker-build` job.\n\nBuild the Docker image and push to Dockerhub. Build the Windows and Linux binaries and upload to Github\nusing `make buildall`. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIzakMarais%2Freporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIzakMarais%2Freporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIzakMarais%2Freporter/lists"}