-
What Grafana version and what operating system are you using?
- 13.1.0 docker image, deployed via Helm in k8s
-
What are you trying to achieve?
- I’ve set up Git provisioning at the root level and am trying to bulk import all our dashboards into our (currently empty) repo.
-
How are you trying to achieve it?
- I have followed the instructions in the documentation to add non-provisioned resources with gcx (see: Add non-provisioned resources from Grafana | Grafana documentation) as it seems to be the only documented way to bulk add resources.
-
What happened?
- The exported JSON files are placed in grafana.app directories (ex: dashboards.v1.dashboard.grafana.app), when committed to the repo and Grafana tries to load them, it complains about these folders missing metadata.json files, and being unable to create the parent folder causing the resources to fail to provision, thus all dashboards continue to be non-provisioned.
-
What did you expect to happen?
- I would expect grafana to successfully load the exported files and bring all my dashboards under git provisioning, allowing changes to be written back to the repo via git sync.
-
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
- There are quite a few, but they all are variations on these two:
folder "dashboards.v0alpha1.dashboard.grafana.app/" is missing folder metadata file - folder UID will be auto-generated and may change on next sync. (file: dashboards.v0alpha1.dashboard.grafana.app/, action: created)
resource was not processed because the parent folder could not be created (file: dashboards.v0alpha1.dashboard.grafana.app/000000048.json, action: ignored)
- There are quite a few, but they all are variations on these two:
-
Did you follow any online instructions? If so, what is the URL?
As an addendum, I also tried moving the files out of those folders to the root of the git repo. This got me somewhat closer, but still doesn’t work as expected producing a slew of messages like this:
writing resource from file 000000005.json: resource validation failed: resource '000000005' already exists and is not managed; repo 'repository-d58714a' cannot take over without an explicit migration (file: 000000005.json, name: 000000005, action: created)
The only dashboards it creates are ones that were originally in folders, but the provisioned copy is placed at the root level (if I’m understanding things properly, this is because those JSON files would need to be placed in a directory in the Git repo in order to create them in a folder inside Grafana, at which point I would expect they would produce the same message as above and fail to provision).
I don’t see anything in the docs about how to do an explicit migration though. Is it an undocumented feature? It seems like there should be an option to automatically do a one-time import when setting up a write-enabled git sync at the root level. Am I missing something?
The resource ... already exists and is not managed ... cannot take over without an explicit migration error suggests the existing dashboards haven’t been migrated into Git Sync management. Grafana provides an experimental “Migrate existing resources” checkbox on the Synchronize with external storage step (Administration → Provisioning → New connection) as the documented one-time migration path for bringing existing unmanaged dashboards under Git Sync.
I’d try recreating the repository connection with Migrate existing resources enabled.
The documented export command is:
gcx resources pull dashboards --path <REPO_PATH>
If that’s the exact command you used, could you share your gcx version? That would help determine whether this is expected behavior for that version or whether you’ve run into a bug.
This never showed up when I was setting up the Git Sync. I just deleted it and ran through the setup again, I see the Synchronize With External Storage step in the sidebar, but Grafana silently skips it every time going straight from step 3 to step 5: Choose Additional Settings.
Version 0.4.4
Commit 72cf9d2fe7882672c9959d00d9a1a5dc56a04029
If the “Synchronize with external storage” step is being skipped entirely, that would explain why you never get the “Migrate existing resources” option required to take over existing dashboards. Since you’re on gcx 0.4.4, this doesn’t seem to be caused by using an outdated CLI version. If that step is consistently skipped on a new Git Sync connection, I’d suggest opening a GitHub issue with the wizard behavior and the relevant Grafana logs.