Hello,
I am currently attempting to write a program using a combination of command line and Python3 that will contact the Grafana server, download a copy of the JSON of one dashboard that I have designated to be the master, create a new JSON which has only the elements necessary to create a new dashboard and the design features that I would like (so id = null, uid = null, title, tags, timezone, refresh, templating, time, and panels, as well as folderUid and overwrite) and replace the device name of the master with the device name of each individual device in turn, and then upload the new dashboard for each device into their own respective folders.
I seem to be stumbling right at the very last hurdle, as I cannot seem to create multiple dashboards from within my Python script. For some reason I get a 412 error saying āthe dashboard has been changed by someone elseā and āversion-mismatchā. This error only occurs if I set overwrite to false, however if I set overwrite to true, the program only seems to create the final dashboard, while the rest of the folders remain empty.
Iām not sure if this is how the API works, but it seems as though you can only handle one dashboard-create per connection to the server (perhaps based on the API key?) per program, which just doesnāt seem right, so I think their must be something I am doing wrong.
I am connecting to the API using GrafanaFace from grafana_api.grafana_face, and then I am running this:
response = requests.post(f"http://localhost:81/api/dashboards/db", headers=headers, data=dashboard_json)
to create the dashboards.
Does anyone have any ideas?
Thanks