I create a grafana organization with m0nhawk's popular Grafana API library for Python with
r = grafana_api.organization.create_organization({"name": organization})
then I switch into that organization and try to list all folders
grafana_api.organizations.switch_organization(organization_id=r[u"orgId"])
grafana_api.folder.get_all_folders()
which yields an empty list.
Then I try to create an initial folder called "General" to fit Grafana's style with
r = grafana_api.folder.create_folder(title="General")
but I get the error:
grafana_api.grafana_api.GrafanaBadInputError: Bad Input: `{'message': 'A folder with that name already exists'}`
If the General
folder already exists, how can I get its folder ID? If it doesn't, how can I create one called "General" without eliciting a GrafanaBadInputError
?
The "General" folder in Grafana is special. It always exists, and always has the
id
of 0.The Grafana documentation has a section on this which says that you can't use the folders api for getting information about the general folder. It does not have a
uid
, so thefolder
operations can't be performed on it (for example, you can't set permissions on it).To get the contents of a folder, you use the search api:
grafana_api.search.search_dashboards(folder_ids=0)
.