1

I have exported the dashboard in json format.

I want to import the json file manually to create the same dashboard in new grafana instance.

While googling i got some related information but finding difficulties to implement successfully.

From the site Grafana API link i got the code snippet like,

POST /api/dashboards/db HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

{ “dashboard”: { “id”: null, “uid”: null, “title”: “Production Overview”, “tags”: [ “templated” ], “timezone”: “browser”, “schemaVersion”: 16, “version”: 0 }, “folderId”: 0, “overwrite”: false }

The above code snippet looks like we can create new dashboard with existing json file but i have no idea of how to implement this code snippet successfully.

Somebody guide me how to achieve this?

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
sivanesan1
  • 779
  • 4
  • 20
  • 44

3 Answers3

3

There are two techniques to copy the current dashboard - if you want to export this

  1. Go to Current Grafana Dashboard
  2. Select the Share button on the top enter image description here
  3. Select the Export Button and Copy the JSON or save it as JSON enter image description here

Create new Grafana dashboard and copy this JSON model to

  • Click on the Setting button on the top
  • Click on JSON Model - from left panel enter image description here
  • Past the JSON & Save the dashboard and run

Please let me know if you have any issue.

Vinay Mishra
  • 386
  • 2
  • 15
  • Hi Tom, Thanks for the response, I have exported the json file as like you mentioned above, Now i need to import the saved json file in my new grafana instance through HTTP API or command line as per the requirement – sivanesan1 Jul 03 '19 at 09:11
  • kindly assist how to import saved json file through HTTP API – sivanesan1 Jul 03 '19 at 09:12
  • I am looking to update the grafana dashboard something like this 'curl --user admin:admin "http://localhost:3000/api/dashboards/db" -X POST -H "Content-Type:application/json;charset=UTF-8" --data-binary @c:/Users/Myname/Desktop/Dashboard.json ' – sivanesan1 Jul 03 '19 at 09:21
  • tell me exactly what you want, it's simple to just similar dashboard launch in a different instance with copy and pastes the json. – Vinay Mishra Jul 03 '19 at 14:42
1

I found and answer to your question - how to import a dashboard in grafana by api - in this post on the community board of Grafana:

https://community.grafana.com/t/how-create-dashboard-and-panel-via-api/10947

Haven't tried this out yet though (we are planning on doing something like this as well).

I will quote the original question in this post:

Hi All,

I know how to create a dashboard via API but I don’t find instructions to how to create panels within that dashboard still via API. Any idea? the part of the message that explains the answer:

And the response that contains the answer to the question:

The panels need to be defined within the JSON that you submit in your POST request. The example in the docs doesn’t spell this out, beyond dashboard – The complete dashboard model

To get hands-on with this, you can (1) create a new dashboard with some panels manually, (2) export that dashboard’s definition as JSON, (3) put the exported dashboard definition inside the “dashboard” field of a new JSON object, (4) POST the resulting JSON object to the API endpoint. This will create a copy of your original dashboard. From there on, you can edit the JSON model you’re posting in order to modify or add any panels you desire.

So to your original question, if you want to add a panel to an existing dashboard you can obtain its definition via the API, add the panel to the JSON object, and push the updated model. (keep the same id/uid and set "overwrite": true)"

Joehannus
  • 21
  • 2
1

Note that (now?) grafana has a nice import function too:

enter image description here

Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69