grafana/grafana
Development workflow
The day-to-day inner loop for changing Grafana. Setup is documented in Getting started — this page focuses on while you're working.
Run servers in two terminals
# Terminal 1: Go backend with hot reload (air)
make run # localhost:3000, login admin/admin
# Terminal 2: Frontend dev server (webpack watch)
yarn startThe Go server proxies the frontend, so visiting http://localhost:3000 always serves the most recent webpack build.
Iterate
- Backend change: save a
.gofile underpkg/. Air will detect the change, recompile, and restart the server. SQLite state underdata/survives restarts so you don't lose dashboards/users. - Frontend change: save a
.ts/.tsxfile underpublic/app/orpackages/. Webpack rebuilds and the browser hot-reloads. - Schema change (CUE under
kinds/or apps): runmake gen-cueormake gen-apps. Air will pick up the regenerated Go. - Feature toggle change: edit
pkg/services/featuremgmt/registry.goand runmake gen-feature-toggles. Commit the regeneratedtoggles_gen.*files.
Frontend tooling notes
- Yarn 4 via Corepack is enforced — don't
npm install. - Workspaces are declared in the root
package.json'sworkspacesarray.packages/grafana-*,public/app/plugins/datasource/<name>(some), and theapps/*test plugins all live as workspaces. - Nx (
nx.json) is used for caching and "affected" runs (yarn nx affected -t test).
Backend tooling notes
- Go workspaces are defined in
go.work. When you add a new module underapps/you must runmake update-workspace. - Wire DI is regenerated with
make gen-go(which runswireagainstpkg/server/wire.go). The generated file ispkg/server/wire_gen.go. make build-backendproducesbin/<arch>/grafana— useful for ad-hoc CLI runs.
Debugging tips
make runbuilds with debug symbols (-gcflags all=-N -l). Attach a Go debugger to PID 0'sbrachild process.yarn starthonors React fast-refresh — most edits do not lose UI state.data/grafana.dbis the SQLite store; you can poke it withsqlite3while the server is stopped.- The default config is a merge of
conf/defaults.iniand anyconf/custom.iniyou create. Many local quirks are easier ascustom.inioverrides than as command-line flags.
See Debugging for more.
Pull request flow
- Branch off
main. - Implement and test.
- Push and open a PR. The PR template asks about user-facing impact and tests.
- Wait for CI: lint, frontend tests, backend tests, e2e, sometimes integration tests against Postgres/MySQL.
- CODEOWNERS-driven reviewers will be auto-requested.
- Address feedback in additional commits — squash on merge keeps the final history clean.
Pre-commit hooks
Lefthook is configured in lefthook.yml. Install with:
make lefthook-installThis runs Prettier, ESLint, and gofmt on staged files. You can skip with git commit --no-verify but CI will catch it.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.