import-dashboards
Import Dashboards as Code
Import existing dashboards from a Grafana instance and convert them to Go
builder code using gcx dev import.
Prerequisites
- gcx installed and configured with a Grafana connection
(
gcx config checkshould show a valid context) - The target Grafana instance must be reachable
Import Commands
Import All Dashboards
gcx dev import dashboards
Writes Go files to imported/ (default). Each dashboard becomes a function
returning *resource.ManifestBuilder.
Import a Specific Dashboard
gcx dev import dashboards/my-dashboard-uid
Import to a Custom Directory
gcx dev import dashboards --path src/grafana
Import Multiple Resource Types
gcx dev import dashboards folders
How It Works
Grafana Instance
│
▼
gcx dev import dashboards/foo
│
├── 1. Fetches resource via K8s API (/apis endpoint)
├── 2. Detects API version (v0alpha1, v1beta1, v2beta1)
├── 3. Runs version-specific converter (JSON → SDK builder code)
├── 4. Wraps in resource.NewManifestBuilder()
└── 5. Writes to imported/<snake_case_name>.go
The converter produces Go code using the grafana-foundation-sdk builder
pattern — the same pattern used by dev generate and dev scaffold.
Output Format
Each imported file looks like:
package dashboards
import (
"github.com/grafana/grafana-foundation-sdk/go/dashboardv2beta1"
"github.com/grafana/grafana-foundation-sdk/go/resource"
)
func MyDashboard() *resource.ManifestBuilder {
// ... builder code generated from the live dashboard
}
Workflow: Import → Edit → Push
# 1. Import from Grafana
gcx dev import dashboards --path internal/dashboards
# 2. Review and edit the generated code
# (fix up builder calls, add variables, etc.)
# 3. Push back to Grafana
gcx resources push
Common Issues
| Issue | Fix |
|---|---|
| "no converter found" | Dashboard uses an unsupported API version; only v0alpha1, v1beta1, v2beta1 supported |
| Auth error (401/403) | Run gcx config check to verify credentials |
| Empty import | The selector matched no resources; check UID with gcx resources get dashboards |
| Imported code doesn't compile | Some complex dashboards produce converter output that needs manual fixup |
More from grafana/gcx
gcx
>
5explore-datasources
Discover what datasources, metrics, labels, and log streams are available in a Grafana instance. Use when the user asks what data exists, what metrics are available, what services are being monitored, or needs to find a datasource UID.
4setup-gcx
>
3gcx-observability
>
3slo-check-status
Use when the user asks about SLO health, wants an overview of all SLOs, or needs status of a specific SLO. Trigger on phrases like "how are my SLOs doing", "SLO status", "check my SLOs", "is my SLO healthy", "SLO budget", "SLO burn rate". For investigating breaching SLOs use slo-investigate. For optimization suggestions use slo-optimize. For creating or modifying SLO definitions use slo-manage.
2slo-investigate
Use when a specific SLO is breaching or alerting and the user needs to understand why — root cause analysis, dimensional breakdown, alert rule correlation, runbook access. Trigger on phrases like "investigate SLO", "why is my SLO breaching", "SLO error budget burning", "SLO alerting". For SLO status overview use slo-check-status. For creating or modifying SLOs use slo-manage. For optimization suggestions use slo-optimize.
2