Unable to import grafana dashboard using exported json through CLI
Asked Answered
E

2

6

I was trying to import dashboard using exported json file from one server to another server of grafana, but getting bellow error;

{"message":"Dashboard not found","status":"not-found"}

My curl command:

  curl -X POST --insecure -H "Authorization: Bearer {API KEY}" -H "Content-Type: application/json" --data-binary @'{JSON file name}' http://{Host ip}:3000/api/dashboards/db

To export dashboard, I am using following curl command; curl -f -k -H "Authorization: Bearer {API key}" "http://{Host IP}:3000/api/dashboards/db/mydashboard" | jq 'del(.overwrite,.dashboard.version,.meta.created,.meta.createdBy,.meta.updated,.meta.updatedBy,.meta.expires,.meta.version)' > {JSON file name}"

  1. I am unable to find exact missing field OR value which is missing OR incorrectly passed through JSON file while importing. Is there any way to debug?
  2. Is there any issue with my Export and import command.
Exoteric answered 19/6, 2018 at 12:11 Comment(1)
Now able to import grafana dashboard using json file. The issue was in the json file. Found solution on bellow link; community.grafana.com/t/…Exoteric
O
7

As mentioned in this issue,

you must replace the "id": num field of the dashboard with null.
so you can change it for all of your dashboards (.json files) by command below: (works with GNU sed only)

sed -i '0,/"id": .*/{s/"id": .*/"id": null,/}' *.json
Orphanage answered 16/9, 2019 at 5:39 Comment(0)
M
0

The simplest solution is to set the 'id' from root of the json to null.

"id": null,

Be aware, it's not the same field as uid in the end of the json (also root). That one must be unique, but not null.

Meteoroid answered 8/2, 2023 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.