← All insightsAutomation

Automating Prometheus from scratch

CodeWizard Academy · 24 May 2026 · 3 min read · Intermediate

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

bash
docker run -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
# open http://localhost:9090

2. Describe the desired state

Scrape config plus an alert rule.

yaml
# 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.

bash
promtool check rules rules.yml
promtool test rules tests.yml

Want 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.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult