Why Grafana dashboards as code starts with a decision about who owns the configuration
Dashboards as code in Grafana starts with one question: who is allowed to change a dashboard, data source or alert rule, and how does that change reach each environment? Teams that answer it first pick a route that fits that answer. Grafana documents three main routes: file provisioning, where YAML or JSON files are loaded at startup, Terraform, where a planned and applied state is managed from outside the instance, and Git Sync, which ties dashboards to a repository. Each route assigns ownership differently. Provisioned files are usually owned by the platform team that deploys Grafana. Terraform shifts ownership to whoever runs the infrastructure pipeline. Git Sync moves authorship toward dashboard authors who work through a repository. The YAML syntax is the easy part.
The harder work is the operating model. A reader with several teams editing in the UI, environments that drift apart, and an auditor asking who changed a panel needs to settle four things before writing any file: who may edit, who approves, how a change moves from a development instance to production, and what happens to a change made directly in the UI. Confirm which of these Grafana features your edition and version support before you commit to a route, because provisioning and Git Sync behave differently across releases. Ask your Grafana contact or check the current provisioning documentation for the exact behavior you rely on.
Decide the ownership model first, then choose the route that enforces it. Write down, for each object type (data sources, dashboards, folders, alert rules, contact points), whether the UI is read-only, reviewed, or open. Teams that skip this step usually end up with a repository that no one trusts, and dashboards that still change by hand. The sections on implementation planning, upgrades and SSO cover scope, version choices and identity; this section is about who holds the pen.
Which Grafana mechanisms can hold configuration as code
Grafana offers several ways to move configuration out of the UI and into files or code. Each one covers a different slice of the instance, so most teams combine two or more. The cards below set out what each route manages, what it leaves to the UI or to other tooling, and what to confirm before you commit a design.
File-based provisioning at startup
Grafana loads data sources, dashboards, plugins and alerting resources from YAML or JSON files when it starts. Files live on the server or in a mounted volume, so they suit container and config-management deployments. Provisioned objects are typically marked read-only in the UI, which is the main guard against drift. Check which alerting resource types and settings the provisioning docs cover for your Grafana version, since coverage changes between releases. Edits made in the UI to provisioned items are not written back to the files.
Provisioning docsTerraform with the Grafana provider
The Grafana Terraform provider manages resources through the Grafana API, including data sources, folders, dashboards and alerting objects. State is kept in your Terraform backend, so plan and apply produce reviewable diffs and fit existing pipelines. It does not manage every Grafana setting, and some objects may need separate handling. Confirm the resource list against the current provider documentation and test how it handles dashboards edited in the UI, since an apply can overwrite those changes.
Git Sync for dashboards
Git Sync is documented by Grafana as an as-code option that connects dashboards to a Git repository so changes move through commits and pull requests. It fits teams that author dashboards in the UI and want history and review without writing JSON by hand. Confirm which resources it covers, how it handles branches and conflicts, and whether it needs a specific Grafana edition or feature flag in your version. Data sources and alert rules may still need one of the other routes.
Gaps that remain in the UI
Some settings sit outside every as-code route, including certain user, team and organization preferences and parts of server configuration. Those stay in grafana.ini or environment variables, or in the UI with an audit trail. Write down which settings are owned by which mechanism before rollout, and assign an owner for each gap. Review the provisioning and Terraform coverage lists together, because a resource covered by one route may be missing from the other.
Choosing between provisioning files, Terraform and Git Sync
This table compares file provisioning, Terraform, Git Sync and a mixed model across ownership, review, secrets, drift and skills. Read each row against your team's existing tooling, since the operational cost of each route depends mostly on who maintains it and how often people still edit in the UI.
| Factor | File provisioning | Terraform | Git Sync and mixed model |
|---|---|---|---|
| Ownership | Platform team owns YAML or JSON files loaded at Grafana startup | Platform or infrastructure team owns HCL state and plan runs | Repository owns dashboards; Git Sync pulls changes into Grafana, and a mixed model splits resources between routes |
| Review workflow | Pull request on files, then a Grafana restart or reload to apply | Pull request with plan output, then apply from a pipeline | Pull request on dashboard JSON; confirm how Git Sync handles merges and failed syncs in your version |
| Secret handling | Credentials are referenced from environment variables or secret files, not stored in the repository | Provider credentials and state need protected storage; confirm state encryption and access controls | Confirm where data source credentials are kept, since repository access can expose dashboard references |
| Drift behavior | Provisioned resources are typically marked as read-only in the UI, which limits edits but needs confirmation per version | Changes made in the UI appear as drift on the next plan and are reverted on apply | Changes made in the UI can be overwritten on the next sync, so teams must agree where edits are allowed |
| Skills needed | YAML or JSON, Grafana configuration, and basic Git practice | HCL, the Grafana provider, state management and pipeline design | Git workflow, dashboard JSON structure and sync configuration |
| Fit for teams that edit in the UI | Weak unless UI-created dashboards are exported and moved into files | Weak for frequent UI editors, who will see plan changes | Strongest when editors work on a branch or in a designated folder; mixed models need clear ownership rules |
| Ongoing operational cost | Low tooling cost; recurring effort goes to file upkeep and restarts | Recurring effort for provider version upgrades, state care and pipeline maintenance | Recurring effort for sync configuration, repository hygiene and resolving conflicts with UI changes |
How to build a dashboards as code pipeline for Grafana
This sequence turns hand-built Grafana dashboards into files in Git that a fresh stack can rebuild, review and promote from one environment to the next. Each step ends with a check that proves the result before the next step starts.
Inventory existing dashboards and data sources
Export the current state of the Grafana instance: data sources, folders, dashboards, alert rules, contact points and notification policies. Record which owner, team or service each item serves, and which items are stale or duplicated. Ask the platform team to confirm where the instance stores its configuration, since a database-backed instance and a file-provisioned instance need different migration handling. The step is done when every dashboard and rule appears on a list with an owner and a keep, rebuild or retire decision.
Set the owned-resource boundary
Decide which resource types the repository will own: data sources, folders, dashboards, alert rules and contact points are the usual candidates, while user-created ad hoc dashboards and personal folders are typically left in the UI. Write the boundary down, including which team may change each type. Confirm with the Grafana provisioning documentation which resource types each mechanism supports in your version, because file provisioning, Terraform and Git Sync do not cover the same set. The step is done when a signed-off table maps each resource type to one management method.
Lay out the repository and branch model
Create a repository with separate directories for provisioning files, dashboard JSON, Terraform modules and per-environment variables, and a README that names the owner of each directory. Keep environment differences in variables or overlays rather than copying files. Protect the main branch so changes arrive through merge requests. The step is done when a clean clone contains every directory and an empty CI pipeline runs on a test branch.
Write data source and folder definitions
Write provisioning files for data sources and folders, with secrets referenced through environment variables or your secret manager instead of stored in Git. Give each data source a fixed UID so dashboards can reference it reliably across environments. Load the files into a local Grafana container and confirm the data sources show a successful connection test. The step is done when a stack started from the repository alone lists every expected data source and folder with no manual clicks.
Convert dashboards to JSON with stable UIDs
Export each in-scope dashboard as JSON, then replace data source references with the fixed UIDs from the previous step and remove values that change on every save, such as version and ID fields. Give every dashboard a stable UID, and move template variables that differ by environment into environment variables or Terraform inputs. Check each file in the Grafana UI after import to confirm panels still render. The step is done when every dashboard file loads without errors and re-exporting it produces no meaningful diff.
Wire validation into CI
Add pipeline stages that lint YAML and JSON, validate Terraform with formatting and plan checks, and start a throwaway Grafana container that loads every provisioning file and reports load errors. Require a passing pipeline and a named reviewer before merge. Include a check that fails when a dashboard file lacks a UID or references an unknown data source. The step is done when a deliberately broken test change fails the pipeline and a valid change passes.
Set up the promotion path per environment
Promote the same committed files through development, staging and production, changing only environment variables and secrets at each stage. Automate the deploy to each stage on merge or on a tagged release, depending on your release policy. Keep a record of which commit runs in each environment. The step is done when a single change moves from development to production without edits to the dashboard files, and the deployed commit matches the tag in each stage.
Lock UI editing and verify no drift
Mark provisioned dashboards and data sources as read-only in the UI so edits cannot silently diverge from Git, and restrict folder permissions to the groups that own them. Then run a rebuild test: restart the stack from scratch, run a plan or compare the exported state against the repository, and confirm no unexpected differences. Schedule the same comparison regularly and alert on drift. The step is done when a restart and a rebuild both produce no diff, and a test UI edit is blocked or detected.
Repository layout and environment promotion that keep dev, staging and production aligned
The core decision is to keep one set of dashboard, data source and alert definitions in version control and vary only the values that differ between environments. Split the repository into three areas: shared modules or reusable JSON and Terraform building blocks, environment overlays that hold only per-environment values (such as the Prometheus or Loki URL, the database host and the folder that a team owns), and a secrets reference layer that points to credentials in your secret manager rather than storing them. A dashboard should exist once in the shared area. If you find yourself copying a dashboard file into a dev and a production folder, the layout is already drifting.
Stability of identifiers matters more than directory names. Dashboard UIDs, data source names and UIDs, folder UIDs and alert rule UIDs are how Grafana and your tooling find a resource again, so they must be identical in every environment. Set them explicitly in code instead of letting Grafana generate them, because a generated UID in dev will not match production and every panel link, alert reference and Terraform state entry that depends on it breaks on the first promotion. Agree a naming convention for these identifiers before the first dashboard is written, and reject changes to them in review. Confirm with your Grafana version's provisioning documentation which fields are honored on each resource type.
Move changes through Git branches or tags with a reviewed merge into the branch or tag that each environment deploys from. Require a pull request for every change, run a validation step (JSON or YAML linting, terraform plan output attached to the review) and promote the same commit or tag from staging to production rather than rebuilding it, so what was tested is what ships. Decide who approves production changes and whether emergency edits are allowed, and write that rule down. Your team's own cadence of promotion is a choice to set, not one this guidance prescribes.
How the pattern changes for single node, HA and Kubernetes deployments
A single Grafana server is the simplest case for file provisioning. Grafana reads YAML or JSON files from its provisioning directories at startup, so the pipeline copies the reviewed files to the host and restarts or reloads the service. Because one process owns the configuration, there is no question about which node has the latest version, and drift is easier to spot by comparing the host directory with the repository.
- File layout: Keep data source, dashboard provider and alerting files in the provisioning directories, and keep dashboard JSON in the path your dashboard provider points to.
- Reload on change: Confirm which resources reload without a restart and which need one. Test this on a staging host before relying on it.
- Single database: A small deployment can use SQLite, but the installation docs say it does not scale for production, so plan for MySQL or PostgreSQL before production use.
- Deploy method: Use the same job for package and container installs so the file paths stay consistent.
- Rollback: Keep the previous commit deployable so a bad dashboard or alert file can be reverted in one step.
Before go-live, confirm the reload behavior for each resource type on your Grafana version and check that a UI edit to a provisioned dashboard is blocked or flagged as intended.
In high availability, two or more active-active Grafana servers sit behind a load balancer and share a MySQL 8.0 or later or PostgreSQL 12 or later database, according to the installation docs. Provisioning files must be identical on every node, because a dashboard or data source that exists on one server and not another produces inconsistent behavior for users. The pipeline therefore has to write the same files to each node, or all nodes have to read from one source, and the rollout has to be checked on every node.
- Identical files: Deploy the same commit to all nodes in the same run and record the commit hash on each one.
- Rolling restarts: Restart nodes one at a time so the load balancer keeps at least one healthy server.
- Alerting duplicates: The HA docs say alerting needs additional configuration to avoid duplicate notifications, so test a firing alert across two nodes before go-live.
- Grafana Live limits: Live streaming features have limitations in HA, so confirm which dashboards depend on them.
- Database access: Provisioned resources land in the shared database, so confirm that every node points to the same database and that backups cover it.
Before go-live, check that each node reports the same provisioned resources and that a test alert produces one notification.
On Kubernetes, the Grafana Helm chart is the usual install path, and provisioning is typically driven through chart values or configuration mounted from ConfigMaps or Secrets. Changes flow through the cluster's deployment process rather than copying files onto hosts. This makes version control of the values file and the mounted content central to the workflow, and it shifts the question from where files live to how the cluster rolls out a new revision.
- Values as code: Store the Helm values file in the same repository as the dashboards and review changes to it like any other code.
- Mounted content: Confirm whether dashboards and data sources are mounted as ConfigMaps and how updates trigger a pod restart or reload.
- Secrets: Keep data source credentials in Kubernetes Secrets or your secret manager, not in the values file.
- Replica count: Multiple replicas raise the same HA questions covered above, including the shared database and alerting deduplication.
- Chart version: Pin the chart version and check the release notes before upgrading.
Before go-live, confirm the chart version you pinned and test a values change in a non-production namespace.
In an air-gapped environment, the pipeline must run inside the network because it cannot reach public repositories, registries or hosted APIs. Packages, container images, Helm charts and Terraform providers have to be mirrored or staged internally before the pipeline can use them. The repository, the Git server and the runner all sit inside the boundary, so access control and audit logs on those systems become part of the Grafana evidence.
- Internal mirrors: Stage the Grafana packages or images, Helm charts and any Terraform provider versions your pipeline needs.
- Terraform state: Store state in a backend inside the network and restrict who can read it, since it can hold sensitive values.
- Internal Git: Confirm that the Git platform and review workflow run inside the boundary and that branch protection and approvals are enforced.
- Update path: Plan how new Grafana releases and patch releases are brought across the boundary and tested before promotion.
- Evidence: Keep pipeline logs and approval records where your compliance team can review them.
Before go-live, confirm with your network and security teams which artifacts can cross the boundary and how they are verified.
Secrets, permissions and drift risks in code-managed Grafana
Dashboards as code moves Grafana configuration into repositories, which creates new places for secrets to leak, new permissions to over-grant and new ways for live instances to drift from what is reviewed. The cards below cover the decisions that keep those risks contained, and the checks to run before a pipeline or service account is trusted with production.
Keep credentials out of Git
Data source passwords, API tokens and OAuth client secrets should never be written into provisioning YAML, Terraform files or dashboard JSON that live in a repository. Reference them through environment variables or a secret store, and confirm that the provisioning files only contain placeholders. Scan commit history as well as the current tree, because a secret removed in a later commit is still exposed. Rotate anything that was ever committed.
Provisioning docsRestrict who can merge
Treat the branch that deploys to production as a control point. Require pull requests, at least one reviewer who did not write the change, and passing validation before merge. Limit direct pushes and force pushes to that branch, and confirm that repository administrators are a short, named list. A reviewer should be able to see which data sources, folders and alert rules a change touches, not only the diff.
Scope service account permissions
Terraform and Git Sync need Grafana credentials that can create and change resources, so they are high-value accounts. Give each pipeline its own service account with the narrowest role that performs its job, and separate staging from production credentials. Ask who can read the pipeline's secret store, because read access to the token is equivalent to the token. Review these accounts on a fixed schedule and remove the ones tied to departed staff or retired pipelines.
Block UI overwrites of provisioned resources
Resources loaded from files are meant to be changed in code, yet editors with access to the UI can still modify or try to change them, which is how drift starts. Confirm which provisioned objects are marked read-only in your Grafana version and which are not. Decide who is allowed to make emergency UI changes, and require that every such change is copied back into the repository within a set window. Without that step, the next deployment will silently revert the fix or keep an unreviewed setting alive.
Harden the Grafana instance itself
Code review protects the definitions, but the running server still needs its own controls. The Grafana security hardening guidance covers cookie and browser settings, restricting unauthenticated access to the metrics endpoint and domain verification. Check these settings in the deployed configuration, since a clean repository does not prove the server is configured the same way. Record which hardening options your team has applied and which it has deliberately left open.
Security hardening docsAudit changes and access
Keep a record of who changed what and when, both in the Git history and in Grafana's own audit trail where your edition provides one. Confirm that pipeline runs are logged, that failed applies are visible, and that log retention meets your internal policy. Ask your team to define which events trigger an alert, such as a new admin account or a provisioned resource changed outside the pipeline. Evidence is only useful if someone reviews it.
How to stop UI edits from drifting away from the repository
Drift is the gap between what the repository says a Grafana instance should contain and what is actually running. It starts the first time someone edits a dashboard in the browser and never exports the change. Stopping it takes three controls: make provisioned resources read-only, decide in advance where UI editing is allowed, and detect drift on a schedule so untracked changes surface quickly. Start by marking every provisioned dashboard as non-editable in its provisioning file, and by setting allowUiUpdates to false on the dashboard provider so Grafana refuses saves that would overwrite file-managed content. Then agree on a written policy: exploratory dashboards may live in a personal or sandbox folder that is excluded from provisioning, while production folders accept changes only through the repository.
Drift detection needs a scheduled job that compares the running state with the repository. For file provisioning, a CI job can export dashboards through the Grafana API and diff them against the committed JSON, ignoring fields Grafana rewrites on save such as version and id. For Terraform, a scheduled terraform plan against the production workspace reports resources changed outside code. Route the output to the team that owns the instance, and treat an unexpected diff as an incident to triage, not a routine merge. When a UI change is worth keeping, export it as JSON, open a pull request, and have a reviewer confirm the panel queries, variables and folder placement before merge.
Be honest about round-tripping. Exported JSON does not always reproduce the original settings, and some UI-only choices, such as certain panel plugin options, library panel references, folder permission details, and alert rule fields that the export or the Terraform provider does not model, may be dropped or reordered. Test each resource type you manage with a change-export-apply cycle in a staging instance before relying on it. Confirm the exact behavior for your Grafana version against the provisioning documentation and your provider's schema, since both change between releases. Keep a short list of resource types where the repository is authoritative and a list where a human-reviewed export is the only path, so drift checks do not produce false alarms that teams learn to ignore.
What drives the effort of moving Grafana configuration into code
This table lists the factors that change how much work it takes to move Grafana data sources, dashboards and alerts into files or Terraform, along with ways to keep each one manageable. Read each row as a question to answer in your written scope, since the effort is set by that scope rather than estimated here. The main takeaway is that inventory and naming decisions made early shrink most of the later work.
| Driver | Why it changes effort | How to keep it down |
|---|---|---|
| Number of dashboards and folders | Each dashboard must be exported, cleaned of UI-only fields and mapped to a folder path in code. | Export and inventory first, retire unused dashboards, and group the rest into a folder structure before converting any of them. |
| Number of data sources and teams | Each data source needs its own connection definition and secret handling, and team ownership determines who reviews changes. | Keep one provisioning file per data source type, and assign each folder an owning team in the repository layout. |
| Count of environments | Dev, staging and production each need their own URLs, credentials and variable values, which multiplies the files to maintain. | Hold environment differences in variables or per-environment inputs so the shared definitions stay identical across stages. |
| Alert rules and notification routing | Alert rules, contact points and notification policies reference data sources and people, and each one needs testing before cutover. | Start with the rules that page people, convert them first, and confirm the routing structure before copying every rule. |
| Legacy UI-only configuration | Settings created by hand in the interface, such as unmanaged users or ad hoc folder permissions, have no file counterpart and must be reverse-engineered. | Record what exists in the UI, decide which items belong in code, and accept that some settings will stay manual with a documented reason. |
| Required approval workflow | A change path with peer review, required checks and merge rules adds pipeline design and access setup on top of the file work. | Confirm the review rules your organization already uses for infrastructure code and reuse them for Grafana changes. |
| Compliance evidence needs | Assessors may ask for proof of who changed what and when, which requires retained history and reviewable records of each change. | Ask an assessor which evidence they expect, then design the repository history and pipeline logs to produce it by default. |
| In-house Terraform or GitOps skills | Teams without Terraform or Git-based deployment experience need training and more review time for the first changes. | Confirm the skills on your team during scoping and decide whether the rollout is built in house, handed over, or paired with a partner. |
| Standardized UIDs and naming | Dashboards and data sources without stable identifiers break references when moved between instances, forcing manual fixes. | Set UID and naming conventions before export, and reuse shared panels or templated queries instead of copying them. |
How to verify the as-code setup works and fails safely
How do I test that my Grafana as-code setup rebuilds from scratch?
Run a clean-environment rebuild test: start an empty Grafana instance with no manual changes, point it at the same repository and provisioning files, and confirm that the data sources, dashboards, folders and alert rules all appear without anyone clicking through the UI. Use a throwaway database rather than the production one so that leftover state cannot hide a missing file. Any resource that exists only after a manual step is a gap in the repository, and it should be fixed before the setup is trusted. Record which version of Grafana the test ran against, because provisioning behavior can differ between releases. Grafana's provisioning documentation describes which resource types load from files at startup, which is the baseline your checklist should follow.
What should a no-diff check after a Grafana restart show?
A restart should produce no change in the provisioned resources: the same data sources, dashboards and alert rules should exist with the same definitions as before the restart. Export or compare the state before and after the restart, using the API or your Terraform plan, and treat any unexpected difference as a finding to explain. If Terraform reports changes immediately after an apply and a restart, the configuration and the running state disagree, and that disagreement is what drift looks like in practice. Confirm that your tooling reads the same instance it writes to, since a second instance can make a clean result meaningless.
How do I confirm CI rejects a broken dashboard or provisioning file?
Commit a deliberately invalid file on a test branch, such as a YAML file with a bad indentation, a missing required key, or a dashboard JSON with a syntax error, and confirm that the pipeline fails before anything reaches the target environment. The check should fail at the validation or plan stage, not after a deploy. Repeat the test with a file that is valid syntax but references a data source that does not exist, because that is a more common real mistake and some validators will not catch it. Your pipeline should block the merge when the check fails. Keep these negative test files in a clearly named folder or branch so they are never promoted to a real environment.
How do I test rollback for Grafana dashboards and alert rules?
Rollback is tested by reverting a known change in Git, applying it through the same pipeline, and confirming that the instance returns to the previous state. Choose a change that touches a dashboard, one data source setting and one alert rule, then revert the commit and check each resource against the earlier definition. Also test what happens to resources that were deleted in the change, since removing a file may or may not remove the object from Grafana depending on how provisioning and Terraform are configured. Write down the expected outcome for each resource type before running the test, so the result is a comparison and not a judgment made afterward.
What happens when someone edits a provisioned dashboard in the Grafana UI?
A UI edit on a provisioned resource should either be blocked or be detected and overwritten at the next sync, and you should confirm which behavior your setup produces. Make a small change to a provisioned dashboard as an editor and check whether Grafana prevents the save, and then check whether the change survives a reload or a Terraform apply. Provisioned dashboards are generally meant to be edited in the repository rather than the UI, so the test should record exactly which resource types are locked and which are not. Document the result so that the team knows what a user can and cannot change, and so the review process matches reality.
What does a fail-safe as-code setup need to protect against?
A fail-safe setup stops bad changes before they reach production and makes unexpected changes visible, so that a failure leaves the environment in a known state. The main protections are validation in CI, a review requirement on the main branch, separate environments with their own state, and drift detection that runs on a schedule. Also confirm that secrets are not stored in the repository and that the pipeline has the least access it needs to each environment. Ask your team or partner to show each protection working in a test run, because a control that has never failed in testing is not yet proven.
Can my own team run these verification checks, or do we need a partner?
Your team can run these checks if it owns the repository, the pipeline and a non-production Grafana instance, and most of the work is repeatable scripting once the tests are defined. A partner is usually brought in to design the test set, build the pipeline gates and review the results against your change process, which is scoped as part of a fixed-scope project. Cost depends on how many data sources, folders and alert rules you have, how many environments need testing, and how much of the pipeline already exists. Ask any provider for a written list of the checks, the environments they cover and what evidence they will hand over at the end.
What to monitor, back up and document after go-live
Once dashboards, data sources and alert rules are defined as code, the main risks shift from building them to keeping the running Grafana in line with the repository. The cards below cover what to watch, what to back up, and what to write down so that the next person can change the setup safely.
Drift reports and UI edits
Grafana still accepts edits in the UI for provisioned objects in many setups, so the running instance can quietly diverge from Git. Decide up front which objects are read-only in the UI and which are allowed to change there. Schedule a comparison of exported dashboards and alert rules against the repository, and treat any difference as either a change to commit or a change to revert. Confirm with your Grafana version which provisioned objects are locked in the interface.
Provisioning docsFailed provisioning load logs
Provisioning files are read at startup, so a malformed YAML file or an invalid dashboard JSON can leave a data source or alert rule missing without an obvious error in the UI. Forward the Grafana server log to your central logging system and alert on provisioning errors during every restart and reload. Check the log after each deployment, not only when someone reports a missing dashboard. Keep a short list of the log messages your team has seen and what each one meant.
Git history as the change record
When provisioning and Terraform are the source of truth, the commit history is the most useful audit trail for dashboards and alert rules. Require pull requests for changes to production folders, include the reviewer and the reason in the commit message, and tag each production promotion. Confirm that your review process can answer who changed an alert threshold and when, without relying on Grafana's own version history, which is a separate record.
Database backups even with config in Git
Config in Git does not replace a backup of the Grafana database. Users, teams, folder permissions, API-created objects, annotations, and any dashboard edits made in the UI live in the database, which is MySQL or PostgreSQL in production. Back up the database on a schedule, test a restore into a separate environment, and document the restore order relative to the provisioning files. Ask your database team which backup tooling and retention they already run.
Schema changes across Grafana upgrades
A Grafana version upgrade can change how provisioned dashboards and alert rules are read or rendered, and Terraform provider versions can change resource fields. Pin the Grafana image and the provider version in the repository, and test each upgrade against a copy of production before promoting it. Review the upgrade notes for breaking changes that touch provisioning, and plan the work with the timing guidance in the Grafana upgrades and support topic.
Upgrade timing docsRunbook for adding sources and dashboards
Write a short runbook for the routine changes your team makes, such as adding a data source, creating a dashboard in a folder, or adding an alert rule. Each step should name the file or Terraform module to edit, the review required, the environment order (development, staging, production), and the check that confirms the change loaded. Include the rollback steps and the owner for each data source credential. Review the runbook after each Grafana upgrade and after any change to the repository layout.
Questions teams ask before they move Grafana into code
How much effort does converting existing Grafana dashboards and alerts to code take?
The effort depends mostly on how many dashboards, folders, data sources and alert rules exist today, how many of them were built by hand in the UI, and how much of their configuration is shared across environments. Start with an inventory: export what is already there, sort it by owner and by how often it changes, and mark which items use secrets or environment-specific values. Each data source, folder and alert rule that needs a reviewed definition adds work, and dashboards with many panels and variables take longer to clean up than simple ones. No fixed duration applies to every estate, so ask any partner for a written estimate based on your inventory and a defined scope. Expect the one-time conversion to cost more than the recurring upkeep afterward.
Can our own platform team convert Grafana to code without a partner?
Yes, a platform team with Git, YAML or JSON and some Terraform experience can do this in-house, and many do. The work that tends to stall in-house is not the file format but the decisions around it: agreeing on a repository layout, deciding which edits stay in the UI, handling secrets, and setting up a review workflow that the dashboard owners will actually use. A partner is useful when those decisions need to be made quickly, when the team has no spare capacity, or when auditors will ask for documented controls. Whichever route you take, make sure one person owns the repository and the promotion process after the project ends.
Should we use file provisioning or Terraform for Grafana?
File provisioning is the simpler starting point: Grafana loads data source, dashboard, plugin and alerting definitions from YAML or JSON files at startup, and the Grafana provisioning documentation describes this as a built-in option. Terraform suits teams that already manage cloud and platform resources with it, want one plan and apply workflow across systems, and need to create objects in several Grafana instances from the same code. Terraform adds state management and a provider dependency to maintain. Many teams use file provisioning for data sources and base folders, then Terraform for alert rules, contact points and access settings. Check which resource types you need before you choose, because not every object type is handled the same way in each method.
Do we need Grafana Enterprise to manage dashboards as code?
No, file-based provisioning is documented for the open source edition, so you do not need Enterprise to define data sources, dashboards and alerting resources in files. Enterprise-only features are a different matter: according to the Grafana authentication docs, SAML, team sync, active sync and SCIM provisioning are available only in Grafana Enterprise and Grafana Cloud. If your identity model depends on team sync or SCIM to keep folder permissions current, that is a reason to consider Enterprise, separate from the code workflow. Confirm current feature availability for your version with Grafana Labs, and compare the licensing terms on the Grafana licensing page before you decide.
What does our team need to provide for a dashboards-as-code project?
The project needs named people who can make decisions, not only technical access. Expect to provide:
- A dashboard owner or data lead for each team whose dashboards will move into code, who can confirm the intended panels and queries
- Administrative access to the Grafana instances in each environment, plus access to the Git hosting platform and any CI runner
- Access to the data sources Grafana queries, such as Prometheus, Loki or SQL databases, so queries can be tested
- A place for secrets, such as your existing secrets manager, and a decision on how credentials reach Grafana
- A decision-maker who approves the repository layout, review rules and who may edit the UI
If these owners are not available, the schedule and quality of the work will suffer, so confirm their time commitment before work begins.
How are promotion and rollback handled across environments?
Promotion means a change moves through a fixed path, such as development, then staging, then production, using the same files or Terraform code with environment-specific values supplied separately. Each change is a commit that goes through a pull request, review and an automated apply, so the Git history records who changed what and when. Rollback is a revert of the commit followed by a re-apply, which works well for dashboards and alert rules but does not undo data that a panel or alert has already sent. Keep environment values out of shared files, pin the Grafana version in each environment, and test rollback in staging before you rely on it. Confirm with your partner or internal team exactly how the pipeline handles deleted objects, because provisioning and Terraform treat removals differently.
How do we stop UI edits from drifting away from the code?
Drift happens when someone edits a dashboard in the Grafana interface and the repository no longer matches the running instance. The usual controls are to make provisioned objects read-only in the UI where your Grafana version allows it, to restrict Editor and Admin roles to the people who own the code, and to run a scheduled plan or comparison that reports differences. Decide in advance whether a UI change is an emergency fix that must be back-ported to Git within a set time, or whether it is simply rejected at the next apply. Confirm the read-only behavior for your Grafana version with the official provisioning documentation before you write the policy.
How DeployOpen scopes, builds and hands over Grafana as-code work
DeployOpen treats Grafana data sources, dashboards and alerts as code that lives in your repository and deploys into your own infrastructure. We agree the scope in writing first, then build the provisioning and Terraform layers, test them in each environment and document how your team runs them day to day.
How we scope
- We inventory existing data sources, dashboards, folders and alert rules to decide what moves into code.
- The written scope names which resources are provisioned from files, which are managed by Terraform and which stay UI-owned.
- We agree the repository layout, environment list and promotion path before any configuration is written.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- We write provisioning files for data sources and dashboards, and Terraform modules for resources that need state tracking.
- Each change is reviewed through pull requests, with plan output checked before anything is applied to a shared environment.
- We configure the instance to load provisioned resources at startup and to mark them as read-only in the UI.
- We test promotion from a development instance to staging and production using the same code and different variables.
How we hand over
- You receive the repository, module code, environment variables and a runbook covering each deployment path.
- The runbook explains how to add a dashboard, how to review a change and how to recover from a failed apply.
- We document how to detect UI edits that drift from code and how your team reconciles them.
- Knowledge transfer sessions walk your engineers through the review workflow before we close the engagement.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Support can cover Grafana version changes that affect provisioning file formats or Terraform provider behavior.
- Ask any provider to confirm which Grafana versions the Terraform provider and Git Sync support in your environment.

