Grafana backup json templates

Carlos Gómez
devops and cross platform development
1 min readNov 9, 2017

--

The first step to create a proper version controller repository for grafana templates is to have a backup of the information. It is easy to export/import grafana dashboards manually but as a devops I prefer automating everything so lets follow some steps to properly backup all your grafana dashboards.

Get your organization ID.

curl -X GET http://<admin_user>:<admin_pass>@localhost:3000/api/orgs

Switch to the organization context to be used by the admin user.

curl -X POST http://<admin_user>:<admin_pass>@localhost:3000/api/user/using/<org_id>

Create an API token for a specific organization.

curl -X POST -H “Content-Type: application/json” -d ‘{“name”:”apikeycurl”, “role”: “Admin”}’ http://<admin_user>:<admin_pass>@localhost:3000/api/auth/keys

Create the script to loop through all grafana dashboards and save a back up of each one of them as a json file.

References:
- http://docs.grafana.org/tutorials/api_org_token_howto/
- https://gist.github.com/crisidev/bd52bdcc7f029be2f295#gistcomment-2147201

--

--

Cloud/Software Architect and DevOps learning about #devops, #cloud, #netcore, #microservices and #newtech