4

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.
dejanualex
  • 3,872
  • 6
  • 22
  • 37
rajendra
  • 73
  • 1
  • 5
  • Now able to import grafana dashboard using json file. The issue was in the json file. Found solution on bellow link; https://community.grafana.com/t/unable-to-create-grafana-dashboard-through-api-but-working-through-ui-import-option-with-same-json-file/2470/5 – rajendra Jun 21 '18 at 12:43

2 Answers2

5

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
Ghasem Pahlavan
  • 661
  • 9
  • 20
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.

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73