Interacts with Grafana and hubot-grafana to provide facility to copy/save Grafana panel images
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial commit Sep 29, 2015
.travis.yml add coveralls token Sep 29, 2015
LICENSE initial commit Sep 29, 2015
Makefile initial commit Sep 29, 2015
README.md update default imageHost value Oct 1, 2015
handlers.go initial commit Sep 29, 2015
handlers_test.go update test data for consistency Sep 29, 2015
main.go update default imageHost value Oct 1, 2015

README.md

grafana-images Build Status Coverage Status

This program interacts with Grafana and hubot-grafana to provide facility to copy/save Grafana panel images to a location on disk. The idea is that this location is then shared by a web server so the images can be publically available. The rough system call diagram is as follows:

grafana-images http call diagram

The HTTP post expected by grafana-images should have two headers and a json payload:

"Accept: application/json"
"Authorization: Bearer grafana-token-goes-here"
{
  "imageUrl": "https://grafana.test.com/render/dashboard-solo/db/sample-dashboard/?panelId=5&width=1000&height=500&from=now-6h&to=now&var-server=test-server"
}

The returned json will have a url that can be used to publically access the Grafana panel image:

{
  "pubImg": "http://grafana.example.com/d494b123e0c40229ca3f1e9015390578.png"
}

In addition to this application, it is assumed that you have a web server set up to serve the saved images at the url returned. All the necessary settings should be configurable:

$ grafana-images --help
Usage of grafana-images:
  -imageHost="http://grafana.example.com/saved-images": host for the saved images
  -imagePath="/opt/saved-images": location on disk where images will be saved
  -port=8080: grafana-images listening port

For more information on how this fits together have a look at ChatOps: Hubot Grafana Images in HipChat.

Building

This will run tests as well.

make

Running

make run

If you want to test the running system, you'll need to send it a json payload along with a couple of headers:

curl -d '{"imageUrl":"https://grafana.test.com/render/dashboard-solo/db/sample-dashboard/?panelId=5&width=1000&height=500&from=now-6h&to=now&var-server=test-server"}' -H "Accept: application/json" -H "Authorization: Bearer 1234567543ewsfdgdh432345awdf=" http://localhost:8080/grafana-images

Test Coverage

make cover