Grafana API – Export Graph as png image

How to export a Grafana Graph as a png image? Step 1) Create your own API Keys 2) Get the Graph URL 3) Export Command

Create your API Key

  • click on the grafana icon at the top left corner and go to Admin (Main Org.) -> API Keys
  • add a new key (example: name=export role=viewer)
  • then you will receive your api key (eyJrIjoieDRzbjh6R1__APIKEY__joiZXhwb3J0IiwiaWQiOjF9)

Get the graph url

  • click on the name of the graph you want to export to a png file
  • select share and copy the url of the „direct link rendered image“ link

(http://192.168.2.132:3000/render/dashboard-solo/db/mathias?panelId=22&from=1467379241365&to=1467400841365&width=1000&height=500)

Put together your export command

You can use curl to download the image file. You will have to set a Bearer token to authenticate.

curl -H „Authorization: Bearer eyJrIjoieDRzbjh6R1__APIKEY__joiZXhwb3J0IiwiaWQiOjF9“ „http://192.168.2.132:3000/render/dashboard-solo/db/mathias?panelId=22&from=now-24h&to=now&width=1000&height=500“ > filename.png

now you can execute your own command and your png file is getting saved to your directory

Example of a exported graph

grafana export png

Source:

https://community.grafana.com/t/is-it-possible-exporting-render-as-a-png-a-especific-panel-in-dashboard/804

8 Kommentare zu „Grafana API – Export Graph as png image“

  1. curl -H “Authorization: Bearer eyJrIjoieDRzbjh6R1__APIKEY__joiZXhwb3J0IiwiaWQiOjF9” “http://192.168.2.132:3000/render/dashboard-solo/db/mathias?panelId=22&from=now-24h&to=now&width=1000&height=500” > filename.png

    where to execute the above command?

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Nach oben scrollen