In big deployments Grafana may have big number of Orgs, datasources, dashboards. If you need to automate provisioning of Grafana resources, you may try to create your own scripts and tools or try to find some open source solutions to cover your use case. This comes down to 2 options: use Grafana API or use file based provisioning.
Typical Use Case
The typical use could be:
-
create Azure AD group for users
-
map Azure AD group and create new Grafana Org
-
create datasources for new Grafana Org
-
provision dashboards for new Grafana Org
Depending on your setup, you may try to keep your dashboards and datasources the same across the Orgs, so you should keep UIDs the same.
Provisioning using grafanactl
# Create New Org and get OrgId
grafanactl create org --name "new-org"
{"message":"Organization created","orgId":9}
# Copy Datasources from default Org (id=1)
grafanactl copy-all-datasources --from-org 1 --to-org 9
✅ Copied datasource loki to org 9
✅ Copied datasource loki-1 to org 9
✅ Copied datasource Mimir to org 9
✅ Copied datasource prometheus to org 9
# Optionally add admin user to new Org
grafanactl add user --name admin --role Admin --org 9
{"message":"User added to organization","userId":1}
This may be easily implemented in simple bash script using jq or similar parsing tools.
Dashboards
Following the logic, you will now have new Org with all datasources defined as in the default Org, using the same UIDs. Now, you can also re-use dashboards defined in main Org and share them with new Org. All queries and links will remain the same because all datasource UIDs and all dashboards UIDs will be the same.