alertmanager
AGENTS.md8.7k starsChanged 5 months agoApache-2.0View on GitHub
Guidance for AI coding agents working in this repository. Keep this file concise and current. For end‑user docs, see README.md and https://prometheus.io/docs/alerting/alertmanager/. Alertmanager handles alerts sent by clients such as Prometheus. It deduplicates, groups, routes, silences, and inhibits alerts, and dispatches them to receiver integrations (email, PagerDuty, Slack, webhook, etc.). Top‑level packages worth knowing: Generated code (do not hand‑edit): Builds and tests are driven by the shared Makefile.common plus the repo‑specific Makefile.
- Installs packages
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 3 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 65
Run a single Go test package or test:
- Distinctive: line 72
Run the UI dev servers directly when iterating on the frontend:
- Very specific: line 91
Follow the lint rules in .golangci.yml.
- Very specific: line 92
Use github.com/stretchr/testify/require, not .../testify/assert.
- Very specific: line 94
Use the standard errors/fmt, not github.com/pkg/errors.
- Very specific: line 99
Keep package‑level documentation up to date (revive: package-comments).
- Very specific: line 107
Run make apiv2 to regenerate api/v2/{models,restapi,client} (requires Docker.
- Very specific: line 108
Run make assets so the Elm UI's Data types stay in sync.
- Very specific: line 109
Update api/v2/api.go handlers for any new operations.
- Very specific: line 112
Do not hand‑edit generated files under api/v2/models, api/v2/restapi, api/v2/client, or ui/app/src/Data.
- Very specific: line 117
Add config in notify/<name>/config.go (struct, validation, defaults) and wire it into config/config.go receivers.
- Very specific: line 119
Add unit tests in the notifier package.
- Very specific: line 120
Update template/default.tmpl only if you are introducing new default templates.
- Distinctive: line 141
If you regenerate API code or UI data, commit the regenerated files alongside the source changes.
- Very specific: line 145
Don't reintroduce APIv1; it was removed in 0.27.0.
- Very specific: line 146
Don't bypass the notification pipeline (notify/notify.go) — new stages should be added as notify.Stage implementations.
- Very specific: line 147
Don't add new top‑level dependencies without checking .golangci.yml depguard rules and go.mod minimums.
- Very specific: line 148
Don't commit generated artifacts unless the corresponding source (openapi.yaml, email.html, etc.) changed in the same commit.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guidance for AI coding agents working in this repository. Keep this file concise and current. For end‑user docs, see README.md and https://prometheus.io/docs/alerting/alertmanager/.
Project overview
Alertmanager handles alerts sent by clients such as Prometheus. It deduplicates, groups, routes, silences, and inhibits alerts, and dispatches them to receiver integrations (email, PagerDuty, Slack, webhook, etc.).
- Language: Go (see
go.modfor the required version, currentlygo 1.26). - Frontend (legacy): Elm app under
ui/app/(Node version pinned in.nvmrc). - Frontend (new): React + TypeScript + Mantine under
ui/mantine-ui/. - API: OpenAPI v2 spec in
api/v2/openapi.yaml; Go server/client/models are generated viascripts/swagger.sh. - Module path:
github.com/prometheus/alertmanager.
Repository layout
Top‑level packages worth knowing:
cmd/alertmanager/— main binary entry point (main.go); thin wrapper that parses flags and callsapp.app/— embeddable Alertmanager runtime extracted fromcmd/alertmanager. Owns the process lifecycle (New/Start/Stop/Reload/Run), subsystem wiring (setup), config-reload subgraph (reloader), listeners andOptions. Lets tests and other binaries run Alertmanager in‑process. See https://github.com/prometheus/alertmanager/issues/406.cmd/amtool/— CLI for interacting with the Alertmanager API.api/— HTTP API.api/v2/is the active REST API;api/connect/is the experimental ConnectRPC API mounted under/api/;api/v1_deprecation_router.goonly returns deprecation responses.cli/—amtoolcommand implementations.cluster/— HA gossip clustering (memberlist-based).config/— YAML config parsing, validation, secrets, coordinator.dispatch/— routing tree, alert grouping, dispatcher loop.inhibit/— inhibition rule engine.mute/,silence/,timeinterval/— muting, silences (with nflog), time‑based mutes.nflog/— notification log (persisted dedup state).notify/— notification pipeline plus one subpackage per integration (slack,pagerduty,email,webhook,discord,jira,msteams,msteamsv2,opsgenie,pushover,rocketchat,sns,telegram,victorops,webex,wechat,mattermost,incidentio).template/— notification templating (Go templates + default email template).template/email.tmplis generated fromtemplate/email.html.provider/mem/— in‑memory alert provider (the only provider).store/— alert/silence store helpers.types/— core domain types (Alert,Silence,Matcher, ...).matcher/— label matcher parsing (used by routes, silences, inhibitions).featurecontrol/— feature flags wired through--enable-feature.limit/,httpserver/,tracing/— server plumbing.ui/web.go— embeds the built UI assets and serves them.examples/,doc/examples/— example configs and HA setups.test/with_api_v2/andtest/cli/— integration/e2e tests.
Generated code (do not hand‑edit):
api/v2/{models,restapi,client}/— regenerated byscripts/swagger.shfromapi/v2/openapi.yaml.ui/app/src/Data/— Elm types generated from the OpenAPI spec.template/email.tmpl— generated fromtemplate/email.htmlviatemplate/Makefile.cluster/clusterpb/cluster.pb.go,nflog/nflogpb/nflog.pb.go,silence/silencepb/silence.pb.go— regenerate viascripts/genproto.shif the.protoschema must change.
Common commands
Builds and tests are driven by the shared Makefile.common plus the repo‑specific Makefile.
make build— buildalertmanagerandamtool(also builds Elm UI assets).make build-all— UI assets + regenerated API + binaries.make build BINARIES=amtool— build a single binary.make assets— regenerate ElmDatatypes andtemplate/email.tmpl.make apiv2— regenerateapi/v2/{models,restapi,client}fromapi/v2/openapi.yaml(runsscripts/swagger.sh; needs Docker).make test— full Go test suite (go test ./...) plus UI tests.make test-short(viaMakefile.common) —go test -short ./....make lint—golangci-lint run(version pinned inMakefile.common) plus UI lint.make common-format—go fmt+golangci-lint fmt(gofumpt + goimports with local prefixgithub.com/prometheus/alertmanager).make fuzz-config— short fuzz run over./config.make clean— remove generated API code, generated email template, and UI build output.
Run a single Go test package or test:
go test ./notify/slack/...
go test ./dispatch -run TestDispatcherRace -vRun the UI dev servers directly when iterating on the frontend:
# Legacy Elm UI
cd ui/app && make build # see ui/app/CONTRIBUTING.md
# New Mantine UI
cd ui/mantine-ui && npm install && npm run devRun Alertmanager locally:
./alertmanager --config.file=doc/examples/simple.yml
# multi-node HA via Procfile (requires goreman):
goreman startConventions
- Follow the lint rules in
.golangci.yml. Notable forbidden imports (enforced bydepguard):- Use
github.com/stretchr/testify/require, not.../testify/assert. - Use
github.com/go-kit/log, notgithub.com/go-kit/kit/log. - Use the standard
errors/fmt, notgithub.com/pkg/errors.
- Use
- Formatting:
gofumpt+goimportswith local prefixgithub.com/prometheus/alertmanager. Runmake common-formatbefore committing. - Comments on exported identifiers must be full sentences ending in a period (
godotlint). - Logging uses
log/slog(sloglint). Prefer structured key/value logging. - Errors: wrap with
fmt.Errorf("...: %w", err)and check witherrors.Is/errors.As(errorlint). - Keep package‑level documentation up to date (
revive: package-comments). - Tests live next to the code as
*_test.go. Larger integration tests live undertest/. Thenotify/testpackage provides shared testing helpers for notifier integrations. - Tests use the standard
testingpackage withtestify/require,t.Runsubtests, andt.Cleanup. - Unit tests run with
t.Parallel(); only the e2e tests stay sequential because API v2 router construction mutates global go-openapi state.
When changing the API
- Edit
api/v2/openapi.yaml. - Run
make apiv2to regenerateapi/v2/{models,restapi,client}(requires Docker; seescripts/swagger.sh). - Run
make assetsso the Elm UI'sDatatypes stay in sync. - Update
api/v2/api.gohandlers for any new operations. - Run
make test lint.
Do not hand‑edit generated files under api/v2/models, api/v2/restapi, api/v2/client, or ui/app/src/Data.
When adding or modifying a notifier
- Each integration lives in its own package under
notify/<name>/. - Add config in
notify/<name>/config.go(struct, validation, defaults) and wire it intoconfig/config.goreceivers. - Register the notifier in
cmd/alertmanager/main.gowhere receivers are built. - Add unit tests in the notifier package; reuse helpers from
notify/test/. - Update
template/default.tmplonly if you are introducing new default templates.
When touching configuration
config/config.goowns top‑level YAML parsing; field changes typically need:- Struct +
yamltags. UnmarshalYAMLvalidation.- Defaults in
DefaultGlobalConfig/ receiver defaults. - Tests in
config/config_test.go, possiblytestdata/fixtures.
- Struct +
- Validate behaviour with
make fuzz-configfor parser changes.
CI expectations
GitHub Actions and CircleCI run build, tests, and golangci-lint. Before pushing:
make common-format
make lint
make testIf you regenerate API code or UI data, commit the regenerated files alongside the source changes.
Things to avoid
- Don't reintroduce APIv1; it was removed in 0.27.0. The only thing left under
api/v1_deprecation_router.gois a deprecation responder. - Don't bypass the notification pipeline (
notify/notify.go) — new stages should be added asnotify.Stageimplementations. - Don't add new top‑level dependencies without checking
.golangci.ymldepguardrules andgo.modminimums. - Don't commit generated artifacts unless the corresponding source (
openapi.yaml,email.html, etc.) changed in the same commit.
Useful references
- Architecture diagram:
doc/arch.svg(sourcedoc/arch.xml). - Example configs:
doc/examples/simple.yml,examples/ha/,examples/webhook/. - Maintainers and ownership:
MAINTAINERS.md,CODEOWNERS. - Release process:
RELEASE.md. - UI contributing guide:
ui/app/CONTRIBUTING.md.
Trending
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about prometheus/alertmanager
- grafana/grafana“Update existing Slack alert message instead of creating new one”GitHub · Jan 2, 2024 · 92 reactions
- cloudflare/unsee“Incompatibility with alertmanager 0.16.x”GitHub · Feb 4, 2019 · 16 reactions
- grafana/mimir“Idea: Update Alertmanager to the newest version (0.28)”GitHub · Jan 21, 2025 · 14 reactions
- prometheus-msteams/prometheus-msteams“Direct integration into Alertmanager?”GitHub · Apr 7, 2023 · 14 reactions
- Stack Overflow“Using alert annotations in an alertmanager receiver”Stack Overflow · Sep 9, 2016 · 14 votes
The biggest 5 of 62 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 62
Talked about on GitHub, Stack Overflow and Bluesky (62 times).
On GitHub · 35
- Jan 2, 2024Update existing Slack alert message instead of creating new one — grafana/grafana92 reactions · 9 comments
- Feb 4, 2019Incompatibility with alertmanager 0.16.x — cloudflare/unsee16 reactions · 7 comments
- Jan 21, 2025Idea: Update Alertmanager to the newest version (0.28) — grafana/mimir14 reactions · 10 comments
- Apr 7, 2023Direct integration into Alertmanager? — prometheus-msteams/prometheus-msteams14 reactions · 5 comments
- Oct 29, 2024AlertManagerConfig: Add support for the new msteamsv2_configs receiver — prometheus-operator/prometheus-operator13 reactions · 14 comments
30 more on GitHub
- May 21, 2020Routing Tree Editor website not accurately simulating routes — prometheus/docs13 reactions · 12 comments
- Oct 10, 2025feat: add incident.io integration to alertmanager — prometheus-operator/prometheus-operator10 reactions · 7 comments
- Apr 9, 2021Support OpsGenie Heartbeat — prometheus-operator/prometheus-operator9 reactions · 5 comments
- Jul 25, 2023Long Alert repeat interval(multiple weeks) realerts ever 5 days — grafana/grafana8 reactions · 13 comments
- Nov 8, 2021Grafana dashboard — coturn/coturn8 reactions · 3 comments
- Apr 7, 2021mute_time_interval support — cloudalchemy/ansible-alertmanager8 reactions · 1 comment
- Sep 8, 2019Discord Support — metalmatze/alertmanager-bot8 reactions
- Aug 11, 2026Add payload field to webhook_configs in VMAlertmanagerConfig CRD and operator validation — VictoriaMetrics/operator6 reactions
- Oct 12, 2023feat: adding alertmanager msteams support — prometheus-operator/prometheus-operator6 reactions · 5 comments
- Apr 18, 2022Add Telegram Receiver type to AlertmanagerConfig CRD — prometheus-operator/prometheus-operator6 reactions · 7 comments
- Oct 26, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 23, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 21, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 20, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 20, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 12, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Oct 8, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Sep 29, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Sep 22, 2026⬆️ [APC Bot] Update alertmanager to v0.34.1 — astronomer/ap-vendor2 reactions
- Sep 15, 2026⬆️ [APC Bot] Update alertmanager to v0.34.0 — astronomer/ap-vendor2 reactions
- Sep 2, 2026⬆️ [APC Bot] Update alertmanager to v0.34.0 — astronomer/ap-vendor2 reactions
- Aug 24, 2026⬆️ [APC Bot] Update alertmanager to v0.34.0 — astronomer/ap-vendor2 reactions
- Aug 19, 2026⬆️ [APC Bot] Update alertmanager to v0.34.0 — astronomer/ap-vendor2 reactions
- Aug 18, 2026⬆️ [APC Bot] Update alertmanager to v0.33.1 — astronomer/ap-vendor2 reactions
- Aug 11, 2026⬆️ [APC Bot] Update alertmanager to v0.33.1 — astronomer/ap-vendor2 reactions
- Aug 4, 2026⬆️ [APC Bot] Update alertmanager to v0.33.1 — astronomer/ap-vendor2 reactions
- Jul 28, 2026⬆️ [APC Bot] Update alertmanager to v0.33.1 — astronomer/ap-vendor2 reactions
- Jul 21, 2026⬆️ [APC Bot] Update alertmanager to v0.33.1 — astronomer/ap-vendor2 reactions
- Jun 22, 2026⬆️ [APC Bot] Update alertmanager to v0.33.0 — astronomer/ap-vendor2 reactions
- Nov 10, 2025Add Alertmanager mixin rules — perses/community-mixins2 reactions
On Stack Overflow · 26
- Sep 9, 2016Using alert annotations in an alertmanager receiver14 votes
- Feb 7, 2022Silence prometheus alerts based on label value / Ignore alerts from label6 votes · 1 answer
- May 31, 2021Alertmanager failing due to "unmarshal errors: line 19: field matchers not found in type config.plain"6 votes · 2 answers
- Aug 19, 2019How to display values of metrics in alert rules prometheus6 votes · 1 answer
- Mar 11, 2020prometheus alert manager config not showing in UI5 votes
21 more on Stack Overflow
- Apr 20, 2016Prometheus using html content in alerts annotations and using it in email template4 votes
- Mar 15, 2020Prometheus' Alertmanager Slack webhook getting "alertmanager.yaml err="unsupported scheme \"\" for URL"3 votes
- Jan 20, 2022Does Prometheus supports webhooks?2 votes
- Jun 16, 2021absent alert getting triggered always in prometheus/alertmanager HA setup2 votes · 1 answer
- Jul 20, 2020Inhibition with exceptions (negative matchers)2 votes · 3 answers
- Jul 2, 2020Alerting in case of exceptions2 votes
- Oct 23, 2018How to configure alerts in Prometheus for diskspace2 votes
- Feb 1, 2023Prometheus alertmanager persistent storage with docker1 vote
- Jul 24, 2020Inhibition with exceptions (negative matchers)1 vote
- Aug 11, 2019Cluster Listen address vs Advertise address in AlertManager1 vote
- Oct 29, 2017How do you monitor kubernetes nodes deployed using kops?1 vote
- Jul 6, 2017Prometheus Alertmanager HA config in config file1 vote · 1 answer
- Oct 22, 2025Alertmanager not able send mails via port 4650 votes
- Jul 31, 2024Converting Teams Webhook with payload type MessageCard to be used in Power Automate "Post to channel when a webhook request is received" workflow0 votes
- Jul 25, 2024Why alertmanager is re-sending notifications after (group_interval + repeat_interval) duration?0 votes
- Nov 28, 2022Prometheus not sending alarms to Alertmanager0 votes
- Nov 10, 2021Prometeus Failed to start TCP listener on \"0.0.0.0\" port 9094:0 votes
- Oct 19, 2021I want to execute shell script through prometheus alert manger when ever alert manager triggers script should execute0 votes
- Dec 23, 2020New Line character in email alerts0 votes
- Aug 12, 2020Inhibition with exceptions (negative matchers)0 votes
- Jul 28, 2020Only trigger a rule after some point in time0 votes · 1 answer
On Bluesky · 1
- Nov 5, 2025📦 prometheus / alertmanager ⭐ 7,299 (+3) 🗒 Go Prometheus Alertmanager — @github-trending.bsky.social2 likes and reposts
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

