Skip to content

Instantly share code, notes, and snippets.

@athoune
Created May 18, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athoune/635b01795cb8e399fa9c to your computer and use it in GitHub Desktop.
Save athoune/635b01795cb8e399fa9c to your computer and use it in GitHub Desktop.
Bootstraping Grafana 2
import requests
import json
s = requests.Session()
r = s.get('http://localhost:3000/login')
print r
r = s.post('http://localhost:3000/login',
data=json.dumps(dict(user="admin", email="", password="admin")),
headers={
'Content-Type': 'application/json;charset=utf-8'
})
print r
r = s.get('http://localhost:3000/api/datasources')
urls = set(data['url'] for data in r.json())
if u'http://localhost:8888' not in urls:
r = s.put('http://localhost:3000/api/datasources',
data=json.dumps({"name": "local",
"type": "graphite",
"url": "http://localhost:8888",
"access": "proxy",
"isDefault": True}),
headers={
'Content-Type': 'application/json;charset=utf-8'
})
print r
print r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment