configure pdf export in grafana6 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

Hi All, this document deals with how to configure pdf exported in grafana
Using this opensource application developed by IzakMarais , we achieved exporting pdf reports from the grafana server. Here are the following steps to follow.

Configuration

Install the dependency packages

yum install texlive-pdftex texlive-latex-bin texlive-texconfig* texlive-latex* texlive-metafont* texlive-cmap* texlive-ec texlive-fncychap* texlive-pdftex-def texlive-fancyhdr* texlive-titlesec* texlive-multirow texlive-framed* texlive-wrapfig* texlive-parskip* texlive-caption texlive-ifluatex* texlive-collection-fontsrecommended texlive-collection-latexrecommended texinfo-tex

Download and install go language,

wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz

tar -C /usr/local -xzf go1.10.2.linux-amd64.tar.gz

export PATH=$PATH:/usr/local/go/bin

Download and install the pdf reporter application

go get github.com/IzakMarais/reporter/...

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

Now start the application by using below command

/root/go/bin/grafana-reporter

Now go to server admin- API keys and create a new key with viewer privileges.
save the token id as it’s required for next step

Now goto Grafana and choose a dashboard which you need to export into pdf.
Goto setting of the dashboard and select add new option from the links tab, configure as below


Type: Link
Url: http://{FQDN neteye server}:8686/api/v5/report/{dashboardUID}?apitoken={tokenid}

Title: PDF
Tooltip: Generate a PDF of this Dashboard
Icon: doc, to be an icon of a document.
Time range: I put mark to allow periods of time.
Variable values: Mark it to play with dates.
Open in a new tab: We mark if we want the PDF to generate it in a new tab.

Then save and continue.

Open the dashboard now you can see the there is an icon for exporting pdf reports.

Here are the parameters supported by pdf exporter

Usage of ./grafana-reporter:
-cmd_apiKey string
Grafana API key. Required (and only used) in command-line mode
-cmd_apiVersion string
Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5 (default "v5")
-cmd_dashboard string
Dashboard identifier. Required (and only used) in command-line mode
-cmd_enable
Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1)
-cmd_o string
Output file. Required (and only used) in command line mode (default "out.pdf")
-cmd_template string
Specify a custom TeX template file. Only used in command line mode, but is optional even there.
-cmd_ts string
Time span. Required (and only used) in command line mode (default "from=now-3h&to=now")
-ip string
Grafana IP and port (default "localhost:3000")
-port string
Port to serve on (default ":8686")
-proto string
Grafana Protocol. Change to 'https://' if Grafana is using https. Reporter will still serve http. (default "http://")
-ssl-check
Check the SSL issuer and validity. Set this to false if your Grafana serves https using an unverified, self-signed certificate. (default true)
-templates string
Directory for custom TeX templates (default "templates/")

This is the sample logs while exporting the report.

 

aph Title:techrunnr Application Status} {Id:78 Type:singlestat Title:SLA}]}
2019/09/09 06:28:47 Downloading image 12 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=12&theme=light&to=now&width=1000
2019/09/09 06:28:47 Downloading image 14 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=14&theme=light&to=now&width=1000
2019/09/09 06:28:47 Downloading image 72 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=72&theme=light&to=now&width=1000
2019/09/09 06:28:47 Downloading image 64 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=64&theme=light&to=now&width=1000
2019/09/09 06:28:47 Downloading image 70 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=70&theme=light&to=now&width=1000
2019/09/09 06:28:50 Downloading image 74 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=74&theme=light&to=now&width=1000
2019/09/09 06:28:50 Downloading image 76 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=76&theme=light&to=now&width=1000
2019/09/09 06:28:51 Downloading image 80 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=150&panelId=80&theme=light&to=now&width=300
2019/09/09 06:28:51 Downloading image 52 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&heig ht=500&panelId=52&theme=light&to=now&width=1000
2019/09/09 06:28:52 Downloading image 54 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=54&theme=light&to=now&width=1000
2019/09/09 06:28:54 Downloading image 66 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=66&theme=light&to=now&width=1000
2019/09/09 06:28:54 Downloading image 56 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=56&theme=light&to=now&width=1000
2019/09/09 06:28:55 Downloading image 58 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=58&theme=light&to=now&width=1000
2019/09/09 06:28:55 Downloading image 81 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=150&panelId=81&theme=light&to=now&width=300
2019/09/09 06:28:56 Downloading image 44 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=44&theme=light&to=now&width=1000
2019/09/09 06:28:56 Downloading image 46 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=46&theme=light&to=now&width=1000
2019/09/09 06:28:58 Downloading image 48 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=48&theme=light&to=now&width=1000
2019/09/09 06:28:59 Downloading image 50 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=500&panelId=50&theme=light&to=now&width=1000
2019/09/09 06:29:00 Downloading image 82 http://localhost:3000/render/d-solo/mmZ5WTdZk/_?from=now-6h&height=150&panelId=82&theme=light&to=now&width=300

21

© 2019, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Related posts

6 Thoughts to “configure pdf export in grafana”

  1. Hi,

    can you please clear two thing, what is below url value would be?
    FQDN neteye server -> What is this fqdn
    dashboardUID -> how will get this

    1. you can get the dashboard ID from the browser URL which you navigate to any grafana dashboard.

      the FQDN is the IP or hostname of the reporter tool got installed.

  2. chris

    I have error after this line any reason anyone can help?

    go get github.com/IzakMarais/reporter/report/…
    go: missing Git command. See https://golang.org/s/gogetcmd
    package github.com/IzakMarais/reporter/report/…: exec: “git”: executable file not found in $PATH

  3. Spyros Anemogiannis

    Hi, thank you for the tips. I followed all instructions, however, when generating a report I get this error :

    “No Image renderer available/installed”

    Any idea what this is happening ?

  4. Spyros

    Hi,

    Followed all instructions and initially I got error about missing Grafana Image Renderer Plugin.

    After installed the Grafana plugin, I get the following:

    error rendering PNGs in parralel for dash {Title:Host Status Description:Status of a server monitored by zabbix agent VariableValues:LOGSPSQL, Windows Servers Rows:[] Panels:[{Id:2 Type:text Title:Host Information GridPos:{H:3 W:4 X:0 Y:0}} {Id:5 Type:stat Title:Uptime GridPos:{H:3 W:4 X:4 Y:0}} {Id:6 Type:singlestat Title:CPU Load GridPos:{H:3 W:4 X:8 Y:0}} {Id:1 Type:singlestat Title:Available Memory GridPos:{H:3 W:4 X:12 Y:0}} {Id:4 Type:singlestat Title:Number of processes GridPos:{H:3 W:4 X:16 Y:0}} {Id:3 Type:singlestat Title:Logged in Users GridPos:{H:3 W:4 X:20 Y:0}} {Id:12 Type:alexanderzobnin-zabbix-triggers-panel Title:Triggers GridPos:{H:9 W:24 X:0 Y:3}} {Id:7 Type:graph Title:CPU Usage GridPos:{H:7 W:8 X:0 Y:12}} {Id:8 Type:graph Title:Available Memory GridPos:{H:7 W:8 X:8 Y:12}} {Id:11 Type:graph Title:Free Swap \% GridPos:{H:7 W:8 X:16 Y:12}} {Id:10 Type:graph Title:Processor Load GridPos:{H:7 W:12 X:0 Y:19}} {Id:9 Type:graph Title:Network Traffic on eth0 GridPos:{H:7 W:12 X:12 Y:19}} {Id:14 Type:graph Title:IO/s GridPos:{H:7 W:12 X:0 Y:26}} {Id:13 Type:graph Title:Filesystems GridPos:{H:7 W:12 X:12 Y:26}}]}: error getting panel {Id:4 Type:singlestat Title:Number of processes GridPos:{H:3 W:4 X:16 Y:0}}: Error obtaining render: 500 Internal Server Error

Leave a Reply