Skip to content

Instantly share code, notes, and snippets.

@jiang-wei
Last active February 13, 2019 15:24
Show Gist options
  • Save jiang-wei/6e6a1fa3e2150f312f7bc2f29233ef26 to your computer and use it in GitHub Desktop.
Save jiang-wei/6e6a1fa3e2150f312f7bc2f29233ef26 to your computer and use it in GitHub Desktop.
create Grafana dashboards by API
Don't use the API as described in http://docs.grafana.org/http_api/dashboard/
Use the undocumented `import` interface
* remove .dashboard.id
-----------------------
data = getDashboard(DA_API_URL, uid, daAuthHeader)
def createDashboard(apiUrl, uid, authHeader, data):
del data['meta']
data['overwrite'] = True
data['folderId'] = 0
data['inputs'] = []
data['dashboard']['id'] = None
#print json.dumps(data, indent=4)
return requests.post(apiUrl + '/dashboards/import' , headers=authHeader, json=data)
---------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment