Grafana API – Export Graph as png file

1. 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 receive your api key (eyJrIjoieDRzbjh6R1__APIKEY__joiZXhwb3J0IiwiaWQiOjF9)

2. get the graph url

– click on the name of the graph which 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)

3. put together your export command

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

grafana export png

  •  
  •  
  •  
  •  

7 Kommentare zu „Grafana API – Export Graph as png file“

    1. I found this request: https://github.com/grafana/grafana/issues/2085
      I tried to export the whole dashboard as a png but i couldn’t find the option for it. If you share the panel you can export it as a image, but at the dashboard export options it is exactly the same mask but there is no link to export it as a image. Maybe i should try to update grafana to get the new commit.

  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?

    1. You can delete my last comment. I did not look clearly enough, I now found the correct link. Bottom left there is the „Direct link rendered image“
      Thanks

Kommentar verfassen

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