Xpersona
G

grafana-foundation-sdk

CLAWHUB · Unverified

Build Grafana dashboards as code with the grafana-foundation-sdk typed builders (TypeScript or Go). Use when creating, modifying, or generating Grafana dashboard JSON programmatically, converting hand-written dashboard JSON to typed code, building monitoring dashboards, or working with Prometheus/Loki queries in dashboards.

62
Rank
84
Safety
1.3k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.3K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17bp3v1hm1dnkzey0c9tfh02183j0y5:grafana-foundation-sdk
  1. Install using `clawhub skill install s17bp3v1hm1dnkzey0c9tfh02183j0y5:grafana-foundation-sdk` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/tenequm/grafana-foundation-sdk before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-tenequm-grafana-foundation-sdk/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

143,510 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: grafana-foundation-sdk
description: Build Grafana dashboards as code with the grafana-foundation-sdk typed builders (TypeScript or Go). Use when creating, modifying, or generating Grafana dashboard JSON programmatically, converting hand-written dashboard JSON to typed code, building monitoring dashboards, or working with Prometheus/Loki queries in dashboards.
metadata:
  version: "0.2.4"
  categories: "operations, development"
  topics: "grafana, dashboards, observability, dashboards-as-code, typescript"
  upstream: "@grafana/grafana-foundation-sdk@0.0.16, github.com/grafana/grafana-foundation-sdk/go@0.0.16"
  openclaw:
    homepage: https://github.com/tenequm/skills/tree/main/skills/grafana-foundation-sdk
    emoji: "📊"
---

# Grafana Foundation SDK

The grafana-foundation-sdk provides strongly typed builder libraries for defining Grafana dashboards as code. Instead of writing raw JSON (which is error-prone and hard to review in diffs), you compose dashboards using chained builder calls that produce valid Grafana JSON.

The SDK is auto-generated from Grafana's internal CUE schemas via the `cog` tool. It supports Go, TypeScript, Python, PHP, and Java. This skill focuses on **TypeScript** (primary) and **Go** (secondary) since those are the most common choices for infrastructure teams.

## When to use this skill

- Creating new Grafana dashboards from scratch
- Converting existing hand-written dashboard JSON to typed code
- Adding panels, variables, or queries to dashboards
- Building reusable dashboard components (helper functions for common panel patterns)
- Generating dashboards dynamically based on service lists or configs

## Installation

The SDK is published as concrete `v0.0.x` tags (latest: **v0.0.16**). Pin explicitly - it is pre-1.0 and the API churns between releases (see Known Gotchas).

**TypeScript:**
```bash
npm install '@grafana/grafana-foundation-sdk@~0.0.16'
# or
pnpm add '@grafana/grafana-foundation-sdk@~0.0.16'
```

**Go:**
```bash
go get github.com/grafana/grafana-foundation-sdk/go@v0.0.16
```

## Core Architecture

Everything follows the **builder pattern**: create a builder, chain configuration methods, call `.build()` (TS) or `.Build()` (Go) to produce the final object. The output is standard Grafana dashboard JSON - compatible with Grafana's API, file-based provisioning, and Kubernetes ConfigMaps.

Each panel type, query type, and variable type lives in its own package. You import only what you need:

```typescript
// Each concern has its own import
import { DashboardBuilder, RowBuilder } from '@grafana/grafana-foundation-sdk/dashboard';
import { PanelBuilder as TimeseriesBuilder } from '@grafana/grafana-foundation-sdk/timeseries';
import { PanelBuilder as StatBuilder } from '@grafana/grafana-foundation-sdk/stat';
import { DataqueryBuilder as PromQueryBuilder } from '@grafana/grafana-foundation-sdk/prometheus';
import { DataqueryBuilder as LokiQueryBuilder } from '@grafana/grafana-foundation-sdk/loki';
```

## 

_meta.json

{
  "ownerId": "kn76gpsgjw5chv0xvzbzcb8cxn81x46r",
  "slug": "grafana-foundation-sdk",
  "version": "0.2.4",
  "publishedAt": 1787313713832
}

references/patterns.md

# Common Dashboard Patterns

## Table of Contents
1. [Project Structure](#project-structure)
2. [RED Method Dashboard](#red-method-dashboard)
3. [Kubernetes Service Dashboard](#kubernetes-service-dashboard)
4. [Loki Log Panels](#loki-log-panels)
5. [Multi-Datasource Dashboard](#multi-datasource-dashboard)
6. [Dynamic Dashboard Generation](#dynamic-dashboard-generation)
7. [Converting Raw JSON to SDK](#converting-raw-json-to-sdk)
8. [Integration with Helm/ConfigMaps](#integration-with-helmconfigmaps)

---

## Project Structure

For a monorepo with multiple dashboards, keep dashboard generators alongside the monitoring config:

```
ops/
  dashboards/
    generate.ts          # entry point - imports and runs all generators
    helpers.ts           # shared datasource refs, query helpers, panel defaults
    overview.ts          # overview dashboard generator
    per-service.ts       # per-service dashboard generator
    package.json         # { "type": "module", "scripts": { "generate": "tsx generate.ts" } }
    tsconfig.json
  deploy/
    dashboards/        # generated JSON files go here
```

Or for a single dashboard, a simple standalone script works fine:

```
ops/dashboards/
  generate-overview.ts
  package.json
```

**package.json:**
```json
{
  "type": "module",
  "scripts": {
    "generate": "tsx generate.ts"
  },
  "dependencies": {
    "@grafana/grafana-foundation-sdk": "^0.0.16"
  },
  "devDependencies": {
    "tsx": "^4.0.0"
  }
}
```

---

## RED Method Dashboard

The RED method (Rate, Errors, Duration) is the standard pattern for monitoring request-driven services. Here's a complete implementation:

```typescript
import { DashboardBuilder, RowBuilder, QueryVariableBuilder, ThresholdsConfigBuilder } from '@grafana/grafana-foundation-sdk/dashboard';
import { PanelBuilder as StatBuilder } from '@grafana/grafana-foundation-sdk/stat';
import { PanelBuilder as TimeseriesBuilder } from '@grafana/grafana-foundation-sdk/timeseries';
import { DataqueryBuilder } from '@grafana/grafana-foundation-sdk/prometheus';
import * as common from '@grafana/grafana-foundation-sdk/common';

// --- Helpers ---

const PROM = { type: 'prometheus', uid: 'prometheus' } as const;

function pq(expr: string, legend?: string) {
  const q = new DataqueryBuilder().expr(expr);
  if (legend) q.legendFormat(legend);
  return q;
}

function defaultTimeseries(title: string) {
  return new TimeseriesBuilder()
    .title(title)
    .datasource(PROM)
    .height(8)
    .span(12)
    .fillOpacity(15)
    .lineWidth(1)
    .showPoints(common.VisibilityMode.Never)
    .legend(
      new common.VizLegendOptionsBuilder()
        .showLegend(true)
        .placement(common.LegendPlacement.Bottom)
        .displayMode(common.LegendDisplayMode.List)
    )
    .tooltip(
      new common.VizTooltipOptionsBuilder()
        .mode(common.TooltipDisplayMode.Multi)
        .sort(common.SortOrder.Descending)
    );
}

// --- Dashboard ---

function buildREDDashboard(namespace: string, metricPref

references/typescript-api.md

# TypeScript API Reference

## Table of Contents
1. [Imports](#imports)
2. [Dashboard Builder](#dashboard-builder)
3. [Panel Types](#panel-types)
4. [Query Builders](#query-builders)
5. [Variable Builders](#variable-builders)
6. [Field Configuration](#field-configuration)
7. [Common Enums](#common-enums)
8. [Go Quick Reference](#go-quick-reference)

---

## Imports

Every concept lives in its own subpath export. Import only what you need:

```typescript
// Dashboard structure
import {
  DashboardBuilder,
  RowBuilder,
  QueryVariableBuilder,
  CustomVariableBuilder,
  DatasourceVariableBuilder,
  DashboardLinkBuilder,
  ThresholdsConfigBuilder,
} from '@grafana/grafana-foundation-sdk/dashboard';

// Panel types (each exports PanelBuilder)
import { PanelBuilder as TimeseriesBuilder } from '@grafana/grafana-foundation-sdk/timeseries';
import { PanelBuilder as StatBuilder } from '@grafana/grafana-foundation-sdk/stat';
import { PanelBuilder as GaugeBuilder } from '@grafana/grafana-foundation-sdk/gauge';
import { PanelBuilder as BarGaugeBuilder } from '@grafana/grafana-foundation-sdk/bargauge';
import { PanelBuilder as TableBuilder } from '@grafana/grafana-foundation-sdk/table';
import { PanelBuilder as PieChartBuilder } from '@grafana/grafana-foundation-sdk/piechart';
import { PanelBuilder as BarChartBuilder } from '@grafana/grafana-foundation-sdk/barchart';
import { PanelBuilder as HeatmapBuilder } from '@grafana/grafana-foundation-sdk/heatmap';
import { PanelBuilder as HistogramBuilder } from '@grafana/grafana-foundation-sdk/histogram';
import { PanelBuilder as LogsBuilder } from '@grafana/grafana-foundation-sdk/logs';
import { PanelBuilder as TextBuilder } from '@grafana/grafana-foundation-sdk/text';
import { PanelBuilder as StateTimelineBuilder } from '@grafana/grafana-foundation-sdk/statetimeline';
import { PanelBuilder as StatusHistoryBuilder } from '@grafana/grafana-foundation-sdk/statushistory';
import { PanelBuilder as NodeGraphBuilder } from '@grafana/grafana-foundation-sdk/nodegraph';
import { PanelBuilder as GeoMapBuilder } from '@grafana/grafana-foundation-sdk/geomap';
import { PanelBuilder as XYChartBuilder } from '@grafana/grafana-foundation-sdk/xychart';
import { PanelBuilder as TrendBuilder } from '@grafana/grafana-foundation-sdk/trend';
import { PanelBuilder as CandlestickBuilder } from '@grafana/grafana-foundation-sdk/candlestick';
import { PanelBuilder as CanvasBuilder } from '@grafana/grafana-foundation-sdk/canvas';
import { PanelBuilder as DatagridBuilder } from '@grafana/grafana-foundation-sdk/datagrid';
import { PanelBuilder as AnnotationsListBuilder } from '@grafana/grafana-foundation-sdk/annotationslist';
import { PanelBuilder as DashboardListBuilder } from '@grafana/grafana-foundation-sdk/dashboardlist';
import { PanelBuilder as NewsBuilder } from '@grafana/grafana-foundation-sdk/news';

// Library panels (reference a shared, server-stored panel)
import { LibraryPanelBuilder } from '@grafana/grafana-foundation-sdk/librarypa

CHANGELOG.md

# Changelog

All notable changes to this skill will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),
and this skill adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.4] - 2026-08-21

### Changed

- Declared ClawHub browse categories (`operations, development`) and topics in `metadata`, so the release pipeline publishes them instead of leaving the skill in the `other` category.

### Removed

- `skill-card.md`. The ClawHub CLI strips a root `skill-card.md` from every publish and the registry generates its own card, so the authored file never reached ClawHub.

## [0.2.3] - 2026-08-07

### Removed

- "Project-Specific Context" section that hardcoded one private repo's Helm chart layout and paths into the published skill.

### Changed

- Genericized example queries and provisioning workflow: `namespace="x402"` -> `namespace="myapp"`, private chart paths -> generic `deploy/dashboards/` layout, `helmfile sync` step -> provisioning-mechanism-agnostic wording.

## [0.2.2] - 2026-07-22

### Added

- skill-card.md release record following NVIDIA's skill-card format
- metadata.openclaw block (emoji, homepage) for ClawHub display

## [0.2.1] - 2026-07-10

### Changed
- CHANGELOG preamble pinned to Keep a Changelog 2.0.0 (format unchanged; KaC 2.0.0 keeps existing changelogs valid).

## [0.2.0] - 2026-06-05

### Fixed
- Go install string corrected to `go get github.com/grafana/grafana-foundation-sdk/go@v0.0.16` (the canonical tag form per the official docs), replacing the stale `@next+cog-v0.0.x` branch ref.
- PieChart legend example now uses `PieChartLegendOptionsBuilder` (from the `piechart` package) instead of `common.VizLegendOptionsBuilder`, which is a type error for piechart panels.

### Added
- `metadata.upstream` tracking established (pinned to v0.0.16).
- Known gotcha on dashboard schema v1 vs v2: the skill targets v1; `dashboardv2beta1` (k8s apiVersion `dashboard.grafana.app/v2beta1`) exists and is still stabilizing.
- Known gotchas on the type-checking gap (builders only checked when wired into a tsconfig; use project-local `npx tsc` for the SDK's ES2024/bundler output) and the regenerate-JSON-after-every-edit discipline.
- `units` typed-constants module, `expr` server-side/SQL expressions, `testdata` datasource, and the broader set of core datasource query builders (elasticsearch, cloudwatch, azuremonitor, googlecloudmonitoring, bigquery, athena, parca, grafanapyroscope) in the TypeScript reference.
- Additional panel types in the import reference: canvas, datagrid, annotationslist, dashboardlist, news; plus `librarypanel`.

### Changed
- Version pins updated to 0.0.16 across SKILL.md (install commands) and references/patterns.md (`package.json` example).

Verified against: @grafana/grafana-foundation-sdk@0.0.16, github.com/grafana/grafana-foundation-sdk/go@0.0.16

## [0.1.0] - 2026-06-05

### Added
- Initial release: building Grafana dashboa

Sponsored

Ads related to grafana-foundation-sdk and adjacent AI workflows.