Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bootstraping Grafana 2
import requests
import json
s = requests.Session()
r = s.get('http://localhost:3000/login')
print r
r ='http://localhost:3000/login',
data=json.dumps(dict(user="admin", email="", password="admin")),
'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}),
'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