Skip to content

Instantly share code, notes, and snippets.

@jaimegago
Created March 5, 2015 02:31
Show Gist options
  • Save jaimegago/c7e15a740c3b874a1ff5 to your computer and use it in GitHub Desktop.
Save jaimegago/c7e15a740c3b874a1ff5 to your computer and use it in GitHub Desktop.
Python script to create and download PNG graphs via Graphite Render URL API
#!/usr/bin/python -tt
import requests
graphite_targets = [
'some.graphite.metric.target',
'another.graphite.metric.target
]
graphite = 'some_graphite_host'
render_url = 'http://%s/render/' % (graphite)
params = {
'width' : 800,
'heigth' : 600,
'format' : 'png'
}
for graphite_target in graphite_targets:
params['target'] = graphite_target
response = requests.get(render_url, params=params)
png_file_path = "/tmpt/%s.png" % graphite_target
png_file = open(png_file_path, "wb")
png_file.write(response.content)
png_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment