osiu97 / reporter

Service that generates a PDF report from a Grafana dashboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grafana reporter

A simple http service that generates *.PDF reports from Grafana dashboards.

demo

Requirements

Runtime requirements

  • pdflatex installed and available in PATH.
  • a running Grafana instance that it can connect to

Build requirements:

Getting started

Build and run

Get the source files and dependencies:

go get github.com/izakmarais/reporter/...

Build and install:

go install -v github.com/izakmarais/reporter/cmd/grafana-reporter

Running without any flags assumes Grafana is reachable at localhost:3000:

grafana-reporter

Query available flags:

grafana-reporter --help

Generate dashboard

Endpoint

The reporter serves a pdf report on the specified port at:

/api/report/{dashBoardName}

where dashBoardName is the same name as used in the Grafana dashboard's URL. E.g. backend-dashboard from http://grafana-host:3000/dashboard/db/backend-dashboard.

Query parameters

Time span : In addition, the endpoint supports the same time query parameters as Grafana. This means that you can create a Grafana Link and enable the Time range forwarding check-box. The link will render a dashboard with your current dashboard time range.

template: Optionally specify a custom TeX template file. template=templateName implies a template file at templates/templateName.tex. The templates directory can be set with a commandline parameter.

apitoken: Optionally specify a Grafana authentication api token. Use this if you have auth enabled on Grafana.

Test

The unit tests can be run using the go tool:

go get github.com/smartystreets/goconvey
go test -v github.com/izakmarais/reporter/...

or, the GoConvey webGUI:

./bin/goconvey -workDir `pwd`/src/github.com/izakmarais -excludedDirs `pwd`/src/github.com/izakmarais/reporter/tmp/

About

Service that generates a PDF report from a Grafana dashboard

License:Apache License 2.0


Languages

Language:Go 100.0%