Skip to content
STACK IT FAST

Grafana

Curated OSSClassicMonitoring & Observability Dashboard20+ people

Audited from github.com/grafana/grafana

Grafana is an open-source observability platform for querying, visualizing and alerting on metrics, logs and traces from many data sources, built as a Go backend organized into independent App Platform modules paired with a large React and TypeScript frontend.

Language
TypeScript
Database
PostgreSQL
Hosting
Docker
License
AGPL-3.0
Running for
10 years
Team
20+ people

Why this architecture

Grafana splits its backend into a growing set of independently versioned Go modules under apps/, tied together by a go.work workspace and modeled with Kubernetes-style APIs (pkg/apiserver, CUE-defined kinds), so individual product areas like alerting or dashboards can evolve without one monolithic backend module.

Tech stack by layer

12 technologies · audited Sep 17, 2026
Frontend & UI
  • ReactThe public/app frontend and the @grafana/ui, @grafana/data and @grafana/runtime SDK packages are React and TypeScript.
  • WebpackProduction build path (scripts/webpack/webpack.prod.ts, webpack.stats.ts) for the frontend bundle.
  • RspackRust-based bundler used for the boot bundle and Swagger docs build (scripts/rspack/rspack.boot.ts, rspack.swagger.ts), alongside Webpack.
Backend & APIs
  • GoCore server (pkg/) and every apps/* module (dashboard, alerting, iam, folder, etc.) are Go, tied together by a go.work workspace.
  • Grafana App Platformapps/ holds ~20 independent Go modules (own go.mod each) for features like iam, dashboard and alerting, replace-linked to the root module.
  • CUEDefines API kinds/schemas (kinds/dashboard) that back the Kubernetes-style API machinery in pkg/apiserver and pkg/apimachinery.
Data & Persistence
  • PostgreSQLPL/pgSQL is the third-largest language by bytes in the repo, indicating Postgres-specific code as a supported storage backend.(inferred)
Infrastructure & Deploy
  • DockerMulti-stage build: alpine/ubuntu base images, a golang:1.26-alpine builder and a node:24-alpine JS builder, copied into a distroless runtime.
  • GitHub ActionsRoughly 96 workflows cover backend/frontend checks, release branching, i18n sync, Storybook and docker builds.
Tooling, Testing & Ops
  • NxOrchestrates cached build and generate targets across the JS/TS workspace.
  • YarnPackage manager for the whole JS/TS workspace (yarn.lock, .yarnrc.yml, .yarn/).
  • LernaPins the shared 13.3.0-pre package version across the workspace and sets yarn as the npm client.
  • JestFrontend unit test runner (jest.config.js, jest.config.codeowner.js).
  • PlaywrightEnd-to-end tests under e2e-playwright/, split into per-feature suites, plus a separate Storybook interaction config.

Grafana architecture diagram

Open SVG
Grafana architecture diagramWeb app → Grafana server (REST); Plugins → Grafana server (SDK); Grafana server → App Platform (API server); App Platform → Grafana DB (resources); Grafana server → Data sources (queries); Alerting → Data sources (evaluate)CLIENTSSERVICESWORKERS & JOBSDATA & STORAGEEXTERNALWeb appReact · @grafana/uiPluginsSDK packagesGrafana serverGo · pkg/App Platformapps/* · K8s-style APIsAlertingapps/alertingGrafana DBPostgreSQL · …Data sourcesvia datasource pluginsAPI serverRESTSDKresourcesevaluatequeries
How the main components of Grafana connect, drawn from the audited repository.
Diagram as text
  • Web app (React · @grafana/ui) → Grafana server (Go · pkg/): REST
  • Plugins (SDK packages) → Grafana server (Go · pkg/): SDK
  • Grafana server (Go · pkg/) → App Platform (apps/* · K8s-style APIs): API server
  • App Platform (apps/* · K8s-style APIs) → Grafana DB (PostgreSQL · …): resources
  • Grafana server (Go · pkg/) → Data sources (via datasource plugins): queries
  • Alerting (apps/alerting) → Data sources (via datasource plugins): evaluate

Key architectural decisions

7 decisions
  1. 01

    apps/ modules are independent Go modules stitched together by go.work

    apps/iam/go.mod, apps/dashboard/go.mod and roughly 18 sibling modules each declare their own module path and use replace directives pointing at the root grafana module and at each other (e.g. github.com/grafana/grafana/apps/advisor => ../advisor); go.work at the repo root ties them into one buildable workspace.

  2. 02

    Internal APIs are modeled Kubernetes-style, not as plain REST CRUD

    pkg/apiserver and pkg/apimachinery implement Kubernetes-style API-server machinery, and kinds/dashboard plus cue.mod/module.cue define resource kinds in CUE, so resources like dashboards get typed schemas and versioned APIs the way Kubernetes custom resources do.

  3. 03

    Two bundlers coexist during a Webpack-to-Rspack migration

    package.json keeps build (Webpack, scripts/webpack/webpack.prod.ts) as the main production build script while build:rspack (scripts/rspack/rspack.prod.ts) and build:rspack:boot (rspack.boot.ts) run the boot bundle and swagger docs through Rspack, letting the migration proceed bundle-by-bundle instead of all at once.

  4. 04

    The plugin SDK ships as roughly twenty separately published npm packages

    packages/grafana-data, grafana-runtime, grafana-ui, grafana-schema, grafana-alerting, grafana-flamegraph, grafana-i18n, grafana-e2e-selectors and others each have their own package.json and version (13.3.0-pre), so datasource and panel plugin authors can depend on just the SDK surface they need rather than the whole grafana package.

  5. 05

    Yarn, Nx and Lerna jointly own the JS/TS monorepo workflow

    yarn.lock and .yarnrc.yml select Yarn as the package manager, nx.json defines cached build/generate targets, and lerna.json sets npmClient: yarn and pins the shared 13.3.0-pre version, splitting install, task caching and version bumping across three purpose-built tools instead of one.

  6. 06

    End-to-end tests are Playwright, organized per product surface

    e2e-playwright/ is split into suites like alerting-suite, dashboards-suite, panels-suite, plugin-catalog-suite and cloud-plugins-suite rather than one flat test directory, with a dedicated playwright.storybook.config.ts alongside the main playwright.config.ts for Storybook-based interaction tests.

  7. 07

    The shipped runtime image is distroless

    The Dockerfile builds the frontend in a node:24-alpine stage and the backend in a golang:1.26.6-alpine stage, then copies both into a gcr.io/distroless/static-debian13 final image, so the running container has no shell or package manager to reduce attack surface.

How Grafana is built

How Grafana is structured

Grafana is two co-located monorepos in one repository. The Go side has a core module (go.mod, module github.com/grafana/grafana) plus roughly twenty independent modules under apps/ — advisor, alerting, annotation, collections, correlations, dashboard, dashvalidator, folder, iam, live, logsdrilldown, playlist, plugins, preferences, provisioning, quotas, scope, secret, shorturl and an example module — each with its own go.mod and replace directives back to the root module and to sibling apps, joined into one buildable workspace by the root go.work. The JS/TS side is a Yarn workspace (package.json, .yarnrc.yml) spanning the public/app frontend and roughly twenty published SDK packages under packages/ (@grafana/data, @grafana/runtime, @grafana/ui, @grafana/schema, and more), orchestrated with Nx (nx.json) and versioned together with Lerna (lerna.json, currently 13.3.0-pre).

Frontend

The main application lives in public/app, built in TypeScript and React on top of the @grafana/* package family: @grafana/data for data-model types, @grafana/runtime for app-level services, and @grafana/ui (referenced by packages/grafana-ui in the workspace) for shared components. Bundling is mid-migration between two tools: package.json's build script still drives Webpack (scripts/webpack/webpack.prod.ts) for the main production bundle, while build:rspack and build:rspack:boot (scripts/rspack/rspack.prod.ts, rspack.boot.ts) use the newer Rust-based Rspack for the boot bundle and the Swagger docs build (build:swagger). Individual datasource plugins that ship in-tree, such as public/app/plugins/datasource/azuremonitor, cloudwatch and graphite, are their own package.json-defined units within the same build.

Backend & APIs

pkg/ holds the core Go server — routing (pkg/router), middleware, plugin management (pkg/plugins), authentication (pkg/login), and more — while apps/ holds the newer "App Platform" modules for specific product areas. Two of the more structurally significant packages are pkg/apiserver and pkg/apimachinery, which implement Kubernetes-style API-server machinery inside Grafana itself; kinds/dashboard and the root cue.mod/module.cue define resource schemas in CUE, the same modeling approach Kubernetes uses for custom resource definitions. This lets a resource like a dashboard get a typed, versioned API schema rather than being one more table behind a hand-written REST handler.

Data & persistence

No specific database driver dependency was directly visible in the audited (size-capped) go.mod, but the repository's own language breakdown shows PL/pgSQL as the third-largest language by bytes (after TypeScript and Go, ahead of CUE, JavaScript and everything else) — a strong signal that a substantial amount of Postgres-specific SQL lives in the codebase, likely for schema migrations and queries against Grafana's own configuration/metadata store. This is noted as inferred rather than confirmed, since the specific driver package was not visible in the size-capped manifest.

Build, test & deploy

CI runs on GitHub Actions with close to 100 workflows covering backend checks (backend-code-checks.yml, backend-unit-tests.yml, go-lint.yml, govulncheck.yml), frontend checks (frontend-lint.yml, frontend-perf-tests.yaml, check-frontend-test-coverage.yml), release management (create-release-branch.yml, release-build.yml, bump-version.yml), i18n (i18n-crowdin-download.yml, i18n-verify.yml) and Storybook deployment (deploy-storybook.yml). Frontend unit tests run on Jest (jest.config.js, plus a separate jest.config.codeowner.js), while end-to-end tests run on Playwright under e2e-playwright/, split into per-surface suites (alerting-suite, dashboards-suite, panels-suite, plugin-catalog-suite, cloud-plugins-suite, and more) with a dedicated playwright.storybook.config.ts for Storybook interaction tests. The production Dockerfile builds the frontend in a node:24-alpine stage and the backend in a golang:1.26.6-alpine stage, then copies both into a gcr.io/distroless/static-debian13 final image with no shell or package manager.

Self-hosting notes

Grafana is widely self-hosted, and this repository builds the same Docker images referenced by its own CI (build-docker-variants.yml, packaging/docker). The devenv/ directory ships a local development environment (devenv/create_docker_compose.sh, devenv/datasources.yaml, devenv/dashboards.yaml) for exercising Grafana against sample data sources and dashboards without a production deployment. Because the backend is split across apps/* Go modules tied together by go.work, self-hosters still consume Grafana as a single compiled binary and Docker image — the modularity is an internal development concern, not something an operator configures directly.

What to copy (and what not to)

Splitting a growing backend into independent Go modules under apps/, joined by a single go.work for local builds, is a pattern worth studying for large Go monoliths that want to reduce coupling between feature teams without a full move to separate services — apps/iam/go.mod's replace block shows the practical cost: every module needs explicit replace directives to every sibling it touches, which is bookkeeping overhead that only pays off once the codebase is large enough to need the isolation. Running two bundlers (Webpack and Rspack) simultaneously during a migration is a reasonable transitional state but not a target architecture to copy outright — it is worth budgeting for finishing the migration rather than treating the dual-bundler setup as a stable equilibrium, since it doubles the build configuration surface that has to be kept correct.

Sources & repo audit

Audited
Sep 17, 2026
Commit
efeddb7
License
AGPL-3.0

Independent analysis of repository at github.com/grafana/grafana. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of Grafana
[![Tech stack of Grafana on STACK IT FAST](https://stackitfast.com/badge/grafana.svg)](https://stackitfast.com/project/grafana)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Grafana's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 62 lines · 8.5 KB
# MISSION: Scaffold "Grafana" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Grafana**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Grafana
- **What It Does**: Grafana is an open-source observability platform for querying, visualizing and alerting on metrics, logs and traces from many data sources, built as a Go backend organized into independent App Platform modules paired with a large React and TypeScript frontend.
- **Domain & Category**: Monitoring & Observability Dashboard
- **Production Scale**: 20+ people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Grafana splits its backend into a growing set of independently versioned Go modules under apps/, tied together by a go.work workspace and modeled with Kubernetes-style APIs (pkg/apiserver, CUE-defined kinds), so individual product areas like alerting or dashboards can evolve without one monolithic backend module.
- **Live Website Reference**: https://grafana.com
- **Source Repository**: https://github.com/grafana/grafana
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Go, React, PostgreSQL, Docker, Nx, Yarn, Webpack, Rspack, CUE, Playwright, Jest
- **Primary Language(s)**: TypeScript, Go
- **License of the reference repo**: AGPL-3.0
- **Frontend**: React — The public/app frontend and the @grafana/ui, @grafana/data and @grafana/runtime SDK packages are React and TypeScript.; Webpack — Production build path (scripts/webpack/webpack.prod.ts, webpack.stats.ts) for the frontend bundle.; Rspack — Rust-based bundler used for the boot bundle and Swagger docs build (scripts/rspack/rspack.boot.ts, rspack.swagger.ts), alongside Webpack.
- **Backend & APIs**: Go — Core server (pkg/) and every apps/* module (dashboard, alerting, iam, folder, etc.) are Go, tied together by a go.work workspace.; Grafana App Platform — apps/ holds ~20 independent Go modules (own go.mod each) for features like iam, dashboard and alerting, replace-linked to the root module.; CUE — Defines API kinds/schemas (kinds/dashboard) that back the Kubernetes-style API machinery in pkg/apiserver and pkg/apimachinery.
- **Data & persistence**: PostgreSQL — PL/pgSQL is the third-largest language by bytes in the repo, indicating Postgres-specific code as a supported storage backend.
- **Infrastructure & deploy**: Docker — Multi-stage build: alpine/ubuntu base images, a golang:1.26-alpine builder and a node:24-alpine JS builder, copied into a distroless runtime.; GitHub Actions — Roughly 96 workflows cover backend/frontend checks, release branching, i18n sync, Storybook and docker builds.
- **Tooling, testing & ops**: Nx — Orchestrates cached build and generate targets across the JS/TS workspace.; Yarn — Package manager for the whole JS/TS workspace (yarn.lock, .yarnrc.yml, .yarn/).; Lerna — Pins the shared 13.3.0-pre package version across the workspace and sets yarn as the npm client.; Jest — Frontend unit test runner (jest.config.js, jest.config.codeowner.js).; Playwright — End-to-end tests under e2e-playwright/, split into per-feature suites, plus a separate Storybook interaction config.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/grafana/grafana @ efeddb7)
1. **apps/ modules are independent Go modules stitched together by go.work**: apps/iam/go.mod, apps/dashboard/go.mod and roughly 18 sibling modules each declare their own module path and use replace directives pointing at the root grafana module and at each other (e.g. github.com/grafana/grafana/apps/advisor => ../advisor); go.work at the repo root ties them into one buildable workspace.
2. **Internal APIs are modeled Kubernetes-style, not as plain REST CRUD**: pkg/apiserver and pkg/apimachinery implement Kubernetes-style API-server machinery, and kinds/dashboard plus cue.mod/module.cue define resource kinds in CUE, so resources like dashboards get typed schemas and versioned APIs the way Kubernetes custom resources do.
3. **Two bundlers coexist during a Webpack-to-Rspack migration**: package.json keeps build (Webpack, scripts/webpack/webpack.prod.ts) as the main production build script while build:rspack (scripts/rspack/rspack.prod.ts) and build:rspack:boot (rspack.boot.ts) run the boot bundle and swagger docs through Rspack, letting the migration proceed bundle-by-bundle instead of all at once.
4. **The plugin SDK ships as roughly twenty separately published npm packages**: packages/grafana-data, grafana-runtime, grafana-ui, grafana-schema, grafana-alerting, grafana-flamegraph, grafana-i18n, grafana-e2e-selectors and others each have their own package.json and version (13.3.0-pre), so datasource and panel plugin authors can depend on just the SDK surface they need rather than the whole grafana package.
5. **Yarn, Nx and Lerna jointly own the JS/TS monorepo workflow**: yarn.lock and .yarnrc.yml select Yarn as the package manager, nx.json defines cached build/generate targets, and lerna.json sets npmClient: yarn and pins the shared 13.3.0-pre version, splitting install, task caching and version bumping across three purpose-built tools instead of one.
6. **End-to-end tests are Playwright, organized per product surface**: e2e-playwright/ is split into suites like alerting-suite, dashboards-suite, panels-suite, plugin-catalog-suite and cloud-plugins-suite rather than one flat test directory, with a dedicated playwright.storybook.config.ts alongside the main playwright.config.ts for Storybook-based interaction tests.
7. **The shipped runtime image is distroless**: The Dockerfile builds the frontend in a node:24-alpine stage and the backend in a golang:1.26.6-alpine stage, then copies both into a gcr.io/distroless/static-debian13 final image, so the running container has no shell or package manager to reduce attack surface.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a monitoring & observability dashboard project?

Copied 12 times · 6 of 6 reported launches succeeded (100%)

Frequently asked about Grafana

What is Grafana built with?

Grafana pairs a Go backend, split into a core module plus roughly twenty independent apps/* Go modules joined by go.work, with a large React and TypeScript frontend built with Webpack and, increasingly, Rspack.

Does Grafana need a database?

Grafana stores its own configuration and metadata in a relational database; a large PL/pgSQL codebase (the third-largest language in the repo by bytes) indicates PostgreSQL is a supported backend, though the exact default was not confirmed from the audited files.

Is Grafana a monorepo?

Yes, in two senses: the JS/TS side is a Yarn workspace managed with Nx and Lerna (packages/, public/app), and the Go side is a multi-module workspace (go.work) spanning the core module and roughly twenty independent apps/* modules.

What is the Grafana App Platform?

It refers to the apps/ directory, where features like iam, dashboard, alerting and folder are each their own Go module with its own go.mod, replace-linked to the root grafana module and to each other, rather than living as packages inside one monolithic backend module.

Does Grafana use Kubernetes-style APIs internally?

Yes. pkg/apiserver and pkg/apimachinery implement Kubernetes-style API-server machinery, and resource schemas (like those under kinds/dashboard) are defined in CUE, modeling Grafana resources the way Kubernetes models custom resources.

Can I self-host Grafana?

Yes, self-hosting is a primary use case. The Dockerfile produces a distroless production image (gcr.io/distroless/static-debian13), and the repository is the same one that ships the grafana/grafana Docker images referenced in its own CI workflows.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md