Last active
February 13, 2019 15:24
-
-
Save jiang-wei/6e6a1fa3e2150f312f7bc2f29233ef26 to your computer and use it in GitHub Desktop.
create Grafana dashboards by API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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