Post

Grafana dashboard via curl

How to import a Grafana dashboard via the HTTP API using curl, including the required JSON structure with id null and the dashboard wrapper.

  • do not forget to add “id: null”
  • encapsulate to {“dashboard”: …}

The following curl command imports a Grafana dashboard via the HTTP API. The JSON payload must be wrapped in a {"dashboard": ...} envelope and the id field should be set to null to create a new dashboard rather than updating an existing one.

1
2
3
4
5
6
7
8
curl -L \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST \
-uadmin \
--data @/tmp/path/dashboards/dashboard.json \
http://hostname/grafana/api/dashboards/db

This post is licensed under CC BY 4.0 by the author.