Skip to content

feat(monitoring): add Prometheus and Grafana to observability stack - #134

Open
tomkabel wants to merge 6 commits into
mainfrom
feat/prometheus-grafana-monitoring
Open

feat(monitoring): add Prometheus and Grafana to observability stack#134
tomkabel wants to merge 6 commits into
mainfrom
feat/prometheus-grafana-monitoring

Conversation

@tomkabel

Copy link
Copy Markdown
Owner

Summary

Adds Prometheus as the metrics collection server and Grafana as the visualization layer to the existing monitoring compose, complementing the existing NetData agents.

Changes

Prometheus (docker-compose.monitoring.yml)

  • Service: prometheus (v2.50.0)
  • Persistent volume: prometheus-data
  • Config: infra/prometheus/prometheus.yml (mounted read-only)
  • Ports: 127.0.0.1:9090 (loopback-only)
  • Health check with /-/healthy endpoint

Grafana (docker-compose.monitoring.yml)

  • Service: grafana (v10.3.1)
  • Persistent volume: grafana-data
  • Provisioning datasources: infra/grafana/datasource.yml (auto-configured Prometheus)
  • Provisioning dashboards: infra/grafana/dashboard-provider.yml
  • Ports: 127.0.0.1:3000 (loopback-only)
  • Default admin credentials: admin/admin (change via env vars)
  • Health check with /api/health endpoint

Infrastructure Config

File Purpose
infra/prometheus/prometheus.yml Scrape targets for Prometheus itself and API service
infra/grafana/datasource.yml Prometheus HTTP API endpoint provisioning
infra/grafana/dashboard-provider.yml File-based dashboard directory provisioning

Usage

# Start with monitoring stack
docker-compose -f docker-compose.yml -f docker-compose.monitoring.yml up -d

# Access Prometheus (local only)
curl http://127.0.0.1:9090

# Access Grafana (local only, default creds admin/admin)
curl http://127.0.0.1:3000

Motivation

NetData provides real-time system metrics but lacks long-term storage and alerting. Prometheus + Grafana provides:

  • Long-term metric retention
  • Custom dashboarding
  • Alerting rules (future)
  • Service-level metrics correlation

Testing

  • docker-compose -f docker-compose.monitoring.yml config validates successfully
  • All services have health checks configured
  • Prometheus config file is mounted correctly

Labels

monitoring

- Adds user_id and optional email to access token payload
- Maintains sub claim for backward compatibility
- Binds request_id to structlog contextvars for correlation
- Replace reset_stuck_jobs with requeue_stuck_jobs in main loop
- Zombie sweeper now writes outbox entry atomically with status update
- Avoids dual-write problem when Redis is unavailable
- Decouples outbox sync interval from cleanup (default 30s)
- Support TEST_DATABASE_URL override for real PostgreSQL tests
- Add test-db and test-redis services to docker-compose.test.yml
- Add postgres hatch script for integration testing
- Keep per-worker SQLite as fast default
- Add prometheus service with persistent volume and health checks
- Add grafana service with datasource and dashboard provisioning
- Configure loopback-only ports for security (127.0.0.1)
- Uses infra/grafana and infra/prometheus config files
@tomkabel tomkabel added the monitoring Observability, metrics, or monitoring label Apr 30, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Vooglaadija Apr 30, 2026
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@tomkabel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 20 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2dbbb63-591e-4e53-b304-03d0ae1a2f30

📥 Commits

Reviewing files that changed from the base of the PR and between 10495dc and 3e74985.

📒 Files selected for processing (8)
  • docker-compose.monitoring.yml
  • docker-compose.test.yml
  • pyproject.toml
  • tests/conftest.py
  • tests/test_worker/test_graceful_shutdown.py
  • tests/test_worker/test_main.py
  • worker/main.py
  • worker/zombie_sweeper.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/prometheus-grafana-monitoring

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
Review rate limit: 0/1 reviews remaining, refill in 34 minutes and 20 seconds.

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

@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
app/api/routes/auth.py 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tomkabel

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

monitoring Observability, metrics, or monitoring

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant