Go library providing core alerting infrastructure for Grafana and Grafana Mimir. Extension of Prometheus Alertmanager with Grafana-specific features.
make test- Run all tests (go test -tags netgo -timeout 30m -race -count 1 ./...)make lint- Run misspell + golangci-lintmake mod-check- Verify go.mod/go.sum are tidymake clean- Remove local tool installations (.tools/)
- Go 1.24, module:
github.com/grafana/alerting - Linter: golangci-lint v2 (config in
.golangci.yml) - Formatters: gofmt + goimports
- Import groups: (1) stdlib, (2) third-party, (3) internal (
github.com/grafana/alerting/...) - Test assertions: use
github.com/stretchr/testify
Each receiver (slack, pagerduty, email, etc.) lives in receivers/<channel>/ with versioned integration subdirs:
v0mimir1/andv0mimir2- Mimir-compatible (Prometheus Alertmanager-style) config. Also they are called legacy.v1/- Grafana-native config.
Each integration has a config struct and a separate schema struct that reflects it. Schema is used to: (1) determine whether a field is secure, (2) render UI components for editing configurations. Grafana integration config has two inputs: settings and secure settings. Secure settings are encrypted fields of the config struct, resolved via a decryption function. When adding a new secure field to a schema, ensure the decryption function is used to read and populate it in the config. When modifying a config struct, always update the corresponding schema to match.
PropertyNamemust equal the JSON tag of the corresponding struct field.- If a field's type is
SecretorSecretURL, setSecure: truein the schema field. - Ignore struct fields whose name contains
FileorRef(e.g.PasswordFile,CAFile,PasswordRef,CARef) — do not add them to the schema. - For inline-embedded structs (e.g.
ProxyConfig \yaml:",inline"`), expand their fields directly into the parent schema usingappend(..., V0ProxyConfigOptions()...)` rather than nesting them in a subform.
receivers/- Notification channels with versioned integrations (see above)notify/- Core alertmanager orchestration (GrafanaAlertmanager, dispatch, stages)definition/- Alertmanager config structs (Route, Config, Receiver)templates/- Go template engine for alert notifications, extended with gomplate functionsmodels/- Shared data models (Alert, Labels, statuses)images/- Alert screenshot/image provider interfacecluster/- Re-exports of Prometheus Alertmanager cluster types
- Receiver configs use a schema versioning system (
receivers/schema/): V0mimir1, V0mimir2, V1 - Factory pattern in
notify/factory.gobuilds receiver integrations by version - Notification history persisted to Loki via
notify/historian/ - Uses Grafana fork of Alertmanager:
github.com/grafana/prometheus-alertmanager