Skip to main content

Semantic linter for Prometheus Alertmanager configs

Project description

amlint

Semantic linter for Prometheus Alertmanager configs.

amtool check-config validates syntax. amlint validates semantics: will alerts actually reach a receiver, does the inhibition rule do anything, are there unreachable routing branches? These are the bugs that burn teams — config is valid, alerts silently vanish.

Why

Alertmanager configs are YAML routing trees with inhibition rules and receivers. The most painful mistakes are syntactically valid:

  • route references a receiver that doesn't exist → alerts are dropped
  • inhibition without equal → silences unrelated alerts, you think it's quiet, there's actually a fire
  • catch-all branch before specific ones → specific branches are unreachable
  • match_re that doesn't compile
  • group_by that doesn't behave the way you think

amtool won't catch any of this. amlint will.

Install

pip install pyyaml
pip install -e .

Usage

amlint check alertmanager.yml
amlint check alertmanager.yml --strict   # WARN also exits non-zero
amlint check alertmanager.yml --format json

Example output:

  ERROR  Route references receiver 'pager-team' which is not defined in receivers. Alerts matched here will be dropped.
  ↳ route.routes[1]  [undefined-receiver]

  WARN   Catch-all route (no matchers) with continue:false will intercept all alerts — 2 subsequent sibling(s) are unreachable.
  ↳ route.routes[0]  [unreachable-route]

  2 error · 3 warn · 1 info

Exit code 1 on ERROR — ready for CI. --strict makes WARN block too.

CI example

# .github/workflows/lint.yml
- name: Lint Alertmanager config
  run: amlint check alertmanager.yml --strict

Checks

code level what it catches
undefined-receiver error route references a receiver that doesn't exist
bad-regex error match_re pattern fails to compile
no-root-route error no root route defined
inhibit-no-equal warn inhibition without equal silences too broadly
unreachable-route warn catch-all hides subsequent sibling routes
groupby-ellipsis warn ... mixed with explicit labels in group_by
inhibit-same-match info source and target match the same label value
unused-receiver info receiver defined but not used in any route

Tests

python3 -m pytest test_linter.py -v

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amlint-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amlint-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file amlint-0.1.0.tar.gz.

File metadata

  • Download URL: amlint-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for amlint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79486d1a5b193179a47b2416c1eb9bbcb29b1cf26901c536ea13ea67d1f1e063
MD5 730fbd405d2dee2a216b1341b49f2d7c
BLAKE2b-256 4ab8b5ec2bcd62b237ebc07d8b18f5940355f59e86b06235a12adc0c67e87a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for amlint-0.1.0.tar.gz:

Publisher: publish.yml on danikdanik2013/amlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amlint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: amlint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for amlint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d38bb673167b626ef8bb2adcb887bb1ef0d00bd08f84c75fadcfbb803bf762a
MD5 4bcc9f92c55a349ea2fbf468bef2b607
BLAKE2b-256 ce9f1fbb1a5a3965e505430b5f1a25faa8f7e1825c17c157e8f66e369cf9f927

See more details on using hashes here.

Provenance

The following attestation bundles were made for amlint-0.1.0-py3-none-any.whl:

Publisher: publish.yml on danikdanik2013/amlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page