<< All versions

Skill v1.0.1

currentAutomated scan100/100
grafana/gcx/import-dashboards

+3 new

──Details
PublishedNovember 15, 2026 at 07:47 AM
Content Hashsha256:0ff5a8813d9df5ca...
Git SHA41df57a4fb09
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 3.1 KB)
SKILL.md3.1 KBactive
SKILL.md · 112 lines · 3.1 KB

name: import-dashboards description: >- Converts existing Grafana dashboards to Go builder code via gcx (dashboards as code). Use to import, migrate, or reverse-engineer a live dashboard into code. For YAML/JSON resource files, use manage-dashboards. metadata: version: "1.0.1"


Import Dashboards as Code

Import existing dashboards from a Grafana instance and convert them to Go builder code using gcx dev import.

Prerequisites

  1. gcx installed and configured with a Grafana connection

(gcx config check should show a valid context)

  1. The target Grafana instance must be reachable

Import Commands

Import All Dashboards

bash
gcx dev import dashboards

Writes Go files to imported/ (default). Each dashboard becomes a function returning *resource.ManifestBuilder.

Import a Specific Dashboard

bash
gcx dev import dashboards/my-dashboard-uid

Import to a Custom Directory

bash
gcx dev import dashboards --path src/grafana

Import Multiple Resource Types

bash
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 the resource API version
├── 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:

go
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

bash
# 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. Render manifests from the builders. In a gcx-scaffolded project,
# `go run .` writes JSON manifests to ./resources
go run .
# 4. Push back to Grafana
gcx resources push

Common Issues

IssueFix
"no converter found"The resource's API version has no converter; the error message names the unsupported version
Auth error (401/403)Run gcx config check to verify credentials
Empty importThe selector matched no resources; check UID with gcx resources get dashboards
Build fails with undefined: cog (or another lowercase SDK identifier)Older gcx versions omit SDK imports from generated files. Add the missing import github.com/grafana/grafana-foundation-sdk/go/<pkg> for each undefined identifier — variants is nested at go/cog/variants. Newer gcx emits complete imports
Imported code doesn't compile for other reasonsComplex dashboards can produce converter output that needs manual fixup: build, read the first error, fix, repeat
← v1.0.0All versions