Anything you do to Prometheus twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.
1. Install it reproducibly
docker run -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
# open http://localhost:90902. Describe the desired state
Scrape config plus an alert rule.
# prometheus.yml
scrape_configs:
- job_name: app
static_configs: [{ targets: ['app:3000'] }]
---
# rules.yml
groups:
- name: app
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 10m
labels: { severity: page }
annotations: { summary: "5xx error rate above 5%" }3. Run it from CI
Unit-test alert rules in CI with promtool.
promtool check rules rules.yml
promtool test rules tests.ymlWant senior help putting Prometheus to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.