How do I get a png of a dashboard graph via the API / render?

  • What Grafana version and what operating system are you using?
    v.7 on Unix

  • What are you trying to achieve?
    I’m trying to use the API to get a rendered PNG image of a dashboard.

  • How are you trying to achieve it?
    I’ve searched through tons of posts to see how to do it with play.grafana.org and none of the following has been working:

curl "http://play.grafana.org/render/dashboard-solo/db/grafana-play-home?orgId=1&panelId=4&from=1498583548146&to=1498590748147&width=1000&height=500&tz=UTC%2B02%3A00" > testdemo.png
curl "https://play.grafana.org/render/dashboard/db/grafana-play-home?orgId=1&from=1577981910905&to=1577989110905&width=1000&height=1500&tz=Europe%2FBudapest" > testdemo.png
  • What happened?
    Both download the png file but it is unopenable. I tried on MacOS and Unix. If I try to open the above links through a browser, it returns a failed to render error.

  • What did you expect to happen?
    I expected it to be an image of the dashboard.

Yo,

Firstly, generate an API KEY since interface admin Grafana then copy the key (also you can define a timelife).
Secondly, try this command for a curl localhost or replace localhost by your ip address;
curl -o NameOfYourDashboard “https://community.grafana.com/render/dashboard/db/DashName?orgId=x&width=2000&height=1500&kiosk=tv” -H “accept: application/json” -H “Authorization: Bearer YouAPIKEY”
Replace the orgId=x by your real orgId and play with width and height for the dimension of you dashboard.

Careful this doesn’t work on Grafana 8.

This topic was automatically closed after 365 days. New replies are no longer allowed.