Grafana dashboards comes empty after importing them via api post requests

  • What Grafana version and what operating system are you using?
    i m using Grafana version 8.5.27 for exporting the dashboards and version 9.5.7 for importing the dashboards, operating system is windows on virtual machine.

  • What are you trying to achieve?
    I need to export all of my dashboards from old instance(version 8.5.27) and then import them to the new instance(9.5.7).

  • How are you trying to achieve it?
    I used a python script and do requests.get method to export the dashboards and then method to import them.

  • What happened?
    after exporting the dashboards, i had to update the json file since we are not able to directly export/import jsons. changing the “id”, “uid”, “folderUid” ect.
    also updated the datasource Uid, so all of my json have the new destination’s datasource uids.
    when i run the python script, i can export and import the dashboards, but when i go to the new instance and try to open the imported dashboards, i get empty charts only.

  • What did you expect to happen?
    I expect to import the dashboard and see all of them are working.
    in all of my exported dashboards, i have 5 or 6 different data source which i already added them on the new instance(some of them have named differently)

  • Did you follow any online instructions? If so, what is the URL?
    i found this instructions similar, but there is no instruction of how he did it
    Importing dashboard JSON results in empty dashboard? - #3 by anenebek

An easier approach is by using the grafana sqllite database migration method. Are you using sqlite3 for grafana backend?

unfortunately, i am not able to use that since our Grafana instance running on cloud and we dont have access to file system. so i had to go with other approach which is writing a python code to do export/import.
i dont know if any other approach is there without me involving to have access to file system or asking the cloud team to do work for me.

1 Like

Are you a paying customer? How many dashboards total do you have?

as of now, in my old instance, i have around 250 dashboards which 45 of them need to be moved to new instance. yes are paying csutomer, but we dont deal with any of them, firm does.
its gaia cloud and last time i tried to reach them but no luck.

1 Like

my issue got resolved and my dashboards all imported to the new instance.
for those who faced with similar issues in future, if you use api get and post request to export and import your dashboards from old instance to new instance you can do as follow.

  1. get the dashboard using requests. Get
  2. do not export them to any path, keep Json in memory.
  3. remove all “id” value and set as empty string
  4. find the folderUid of your new instance and add it to your func in post request in order to import them in a folder you want.
  5. replace the values of all datascource’s uid with a new uid you get from new instance.
  6. from json file you just need the part start from “dashboard” or “annotations”. remove the rest of them. you dont need meta, or folders …
  7. make sure the have the exact data source name in both instance. otherwise it will be empty dashboards.
  8. you don’t need to have the exact Grafana version. my old version was 8.5 and new was 9.5.7
    hope this helps anyone who interested to do export/import using api request.