Skip to content

feat: prometheus alerting rules - #129

Open
0xaboomar wants to merge 2 commits into
mainfrom
feat/prometheus-alerting-rules
Open

feat: prometheus alerting rules#129
0xaboomar wants to merge 2 commits into
mainfrom
feat/prometheus-alerting-rules

Conversation

@0xaboomar

@0xaboomar 0xaboomar commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added centralized alert management with grouped notifications, delayed delivery, repeat reminders, and resolved-alert updates.
    • Added monitoring alerts for stale feeds, low trip- and stop-matching quality, and unavailable watchdog services.
    • Configured monitoring to automatically discover alert rules and forward notifications.
  • Operations

    • Added the alert management service to the monitoring environment for improved incident visibility.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The monitoring stack now loads Prometheus alert rules, detects feed and watchdog failures plus prediction-quality issues, and routes alerts through a new Alertmanager service to an internal webhook.

Changes

Prometheus alerting pipeline

Layer / File(s) Summary
Alert rule definitions
prometheus/rules/*
Added alerts for stale feeds, low trip-match and stop-match ratios, and unavailable watchdog metrics.
Prometheus and Alertmanager configuration
prometheus/prometheus.yml, prometheus/alertmanager.yml
Prometheus loads rule files and targets Alertmanager. Alertmanager groups alerts and sends firing and resolved notifications to the configured webhook.
Docker Compose service wiring
docker-compose.yml
Prometheus mounts the rule directory and starts with Alertmanager. The new Alertmanager service mounts its configuration, exposes port 9093, and joins the observability network.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Prometheus
  participant Alertmanager
  participant InternalWebhook
  Prometheus->>Prometheus: Evaluate configured alert rules
  Prometheus->>Alertmanager: Send firing or resolved alerts
  Alertmanager->>InternalWebhook: Send grouped webhook notification
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added Prometheus alerting rules and related configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/prometheus-alerting-rules

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 51.371%. remained the same — feat/prometheus-alerting-rules into main

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker-compose.yml`:
- Around line 33-34: Update the Alertmanager service volume configuration
alongside the existing alertmanager.yml bind mount to add a named volume for
Alertmanager’s data directory, and declare that named volume in the compose
configuration so silences and notification history survive container
replacement.
- Around line 35-36: Restrict the Alertmanager management endpoint in the
service ports configuration by binding port 9093 to host loopback instead of all
interfaces. Preserve container port 9093 while preventing direct access from
untrusted hosts, and ensure any reverse-proxy or firewall policy allows only
trusted operators.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 07cba630-8211-4f89-8809-5f8b5d102eca

📥 Commits

Reviewing files that changed from the base of the PR and between a608802 and ef613fe.

📒 Files selected for processing (6)
  • docker-compose.yml
  • prometheus/alertmanager.yml
  • prometheus/prometheus.yml
  • prometheus/rules/feed_staleness.yml
  • prometheus/rules/prediction_quality.yml
  • prometheus/rules/watchdog_meta.yml

Comment thread docker-compose.yml
Comment on lines +33 to +34
volumes:
- ./prometheus/alertmanager.yml:/etc/alertmanager/alertmanager.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Persist Alertmanager state in a named volume.

This mount supplies only configuration. The service has no explicit data mount, so a container replacement can lose silences and notification-log state. Alertmanager persists both state types; losing them can restore muted alerts and cause duplicate notifications. (prometheus.io)

Proposed fix
   alertmanager:
     volumes:
       - ./prometheus/alertmanager.yml:/etc/alertmanager/alertmanager.yml
+      - alertmanager-data:/alertmanager
+
+volumes:
+  alertmanager-data:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
volumes:
- ./prometheus/alertmanager.yml:/etc/alertmanager/alertmanager.yml
volumes:
- ./prometheus/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- alertmanager-data:/alertmanager
volumes:
alertmanager-data:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` around lines 33 - 34, Update the Alertmanager service
volume configuration alongside the existing alertmanager.yml bind mount to add a
named volume for Alertmanager’s data directory, and declare that named volume in
the compose configuration so silences and notification history survive container
replacement.

Comment thread docker-compose.yml
Comment on lines +35 to +36
ports:
- "9093:9093"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files:\n'
git ls-files | rg '(^|/)docker-compose\.ya?ml$|alertmanager|promtail|prometheus' || true

printf '\nRelevant compose snippets:\n'
if [ -f docker-compose.yml ]; then
  nl -ba docker-compose.yml | sed -n '1,120p'
fi

printf '\nSearch for Alertmanager auth/reverse proxy/firewall config:\n'
rg -n 'alertsmanager|Alertmanager|alertmanager|web\.authorization|basic_auth|password_file|forwardauth|auth_request|allow.*9093|block.*9093|port.*9093|bindaddr|listen:' -S . || true

Repository: OneBusAway/watchdog

Length of output: 464


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'docker-compose.yml:\n'
cat -n docker-compose.yml | sed -n '1,120p'

printf '\nprometheus/alertmanager.yml:\n'
cat -n prometheus/alertmanager.yml | sed -n '1,220p'

printf '\nSearch for Alertmanager-related auth, proxy, or network controls:\n'
rg -n -S 'alertmanager|Alertmanager|9093|authorization|basic_auth|password|forwardauth|auth_request|allow|block|bindaddr|listen|web\.http' . || true

printf '\nSearch for firewall/network policy mentions:\n'
rg -n -S 'firewall|iptables|ufw|nginx|nginx-proxy|traefik|haproxy|caddy|cloudflare|access|allow|block|trusted|operator' . || true

Repository: OneBusAway/watchdog

Length of output: 11276


Broken Authentication (CWE-306): Missing Authentication for Critical Function

Reachability: External

Restrict the Alertmanager management endpoint.

"9093:9093" publishes Alertmanager on the Docker host without authentication or documented access control. Clients that reach this port can create a broad silence and suppress webhook notifications. Bind the port to loopback, or use authenticated ingress; verify that host firewall and reverse-proxy policy restrict port 9093 to trusted operators.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` around lines 35 - 36, Restrict the Alertmanager
management endpoint in the service ports configuration by binding port 9093 to
host loopback instead of all interfaces. Preserve container port 9093 while
preventing direct access from untrusted hosts, and ensure any reverse-proxy or
firewall policy allows only trusted operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants