Deploy Grafana OnCall on Docker: Self-Hosted On-Call Scheduling & Alert Routing

DevOps tutorial - IT technology blog
DevOps tutorial - IT technology blog

The 2 AM Production Outage: Why Raw Alerts Aren’t Enough

At 2:14 AM, your primary API starts throwing HTTP 502 errors. A stuck background worker just ate all 200 connections in your PostgreSQL pool. Prometheus fires an alert into a shared #alerts Slack channel, and then nothing happens. Ten minutes pass. Half the team muted that channel after a noisy staging deploy last month, while the rest have Do Not Disturb active on their phones.

Most engineering teams hit one of two walls here. Either nobody knows who owns the 2 AM page, or the finance team balks at paying $21 to $41 per seat every month for PagerDuty. For a 15-person engineering org, per-seat SaaS incident management easily runs $3,800 to $7,300 a year—just to route webhooks and wake someone up.

Self-hosting Grafana OnCall on Docker solves both problems without the recurring bill. You get proper on-call rotations, multi-step escalation chains, and direct Slack or Telegram pings on a single 2 vCPU, 2 GB RAM VPS. Best of all, your incident pipeline stays inside your own network.

Core Concepts: How Grafana OnCall Routes an Incident

Four building blocks turn a raw metric spike into an acknowledged incident:

  • Integrations: Entry points for incoming alerts. Grafana OnCall generates unique webhook URLs for Prometheus Alertmanager, Grafana Alerting, Zabbix, or generic JSON payloads.
  • Alert Groups: Deduplication for noisy failures. Instead of paging you 40 times when 40 Kubernetes pods crash from one bad config, OnCall groups them into a single thread with Firing, Acknowledged, and Resolved states.
  • Escalation Chains: Timed fallback rules. For example, ping the primary engineer on Telegram immediately, wait 5 minutes, and escalate to the backup lead on Slack if nobody hits Acknowledge.
  • On-Call Schedules: Weekly or daily rotations that track who is primary and backup at any hour. Build them in the UI, or sync an existing Google Calendar or iCal feed.

The Docker stack itself is lightweight and splits into five containers. Grafana serves the UI with the OnCall plugin enabled, while the OnCall Engine (a Python/Django service) handles API requests and webhooks. A Celery worker processes background timers, backed by Redis for task queueing and a database—SQLite for quick tests, or PostgreSQL/MySQL in production.

Hands-On: Deploying Grafana OnCall on Docker

You will need a Linux host with Docker and Docker Compose v2 installed, plus roughly 1 GB of free RAM. Keep ports 3000 and 8080 open locally, or front them with Nginx, Caddy, or Traefik for TLS.

1. Create the Docker Compose Stack

Start by creating a project directory and an .env file for your domain and secrets:

mkdir -p ~/grafana-oncall && cd ~/grafana-oncall

cat << 'EOF' > .env
DOMAIN=http://localhost:8080
SECRET_KEY=replace_this_with_a_long_random_hex_string
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=StrongPassword2026!
EOF

Deploying on a cloud VM? Swap http://localhost:8080 for your public domain so webhook callbacks and Slack interactive buttons resolve properly. Run openssl rand -hex 32 to generate a real 64-character SECRET_KEY.

Save the following service definitions to docker-compose.yml:

services:
  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redis_data:/data

  engine:
    image: grafana/oncall:latest
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      BASE_URL: ${DOMAIN}
      SECRET_KEY: ${SECRET_KEY}
      BROKER_TYPE: redis
      REDIS_URI: redis://redis:6379/0
      GRAFANA_API_URL: http://grafana:3000
      DATABASE_TYPE: sqlite3
      FEATURE_PROMETHEUS_EXPORTER_ENABLED: "true"
    volumes:
      - oncall_data:/var/lib/oncall
    depends_on:
      - redis

  celery:
    image: grafana/oncall:latest
    restart: unless-stopped
    command: sh -c "./celery_with_exporter.sh"
    environment:
      BASE_URL: ${DOMAIN}
      SECRET_KEY: ${SECRET_KEY}
      BROKER_TYPE: redis
      REDIS_URI: redis://redis:6379/0
      GRAFANA_API_URL: http://grafana:3000
      DATABASE_TYPE: sqlite3
    volumes:
      - oncall_data:/var/lib/oncall
    depends_on:
      - redis
      - engine

  grafana:
    image: grafana/grafana:latest
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER}
      GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD}
      GF_INSTALL_PLUGINS: grafana-oncall-app
    volumes:
      - grafana_data:/var/lib/grafana
    depends_on:
      - engine

volumes:
  redis_data:
  oncall_data:
  grafana_data:

Bring the containers up and tail the logs to watch the initial database migrations:

docker compose up -d
docker compose logs -f engine grafana

First boot takes 30 to 60 seconds while Grafana downloads the grafana-oncall-app plugin. Once the HTTP server is listening, browse to http://<your-server-ip>:3000 and sign in with your admin credentials.

2. Connect Grafana to the OnCall Engine

Open Alerts & IRM > OnCall (or Connections > Plugins > Grafana OnCall) in the Grafana sidebar. Click Enable, then set the OnCall API URL to http://engine:8080. Both containers share the default Compose network, so they talk over internal DNS without exposing the engine port publicly.

3. Build an On-Call Schedule and Escalation Chain

Let’s wire up the 2 AM database outage workflow:

  1. Open OnCall > Schedules and click Create Schedule. Name it Primary Production Rotation, set your timezone, and add at least two engineers to a weekly rotation.
  2. Navigate to OnCall > Escalation Chains and create a chain named Critical Prod Escalation.
  3. Add Step 1: Notify users in schedule → select Primary Production Rotation.
  4. Add Step 2: Wait 5 minutes.
  5. Add Step 3: Notify user and pick a backup lead or secondary schedule in case the primary misses the page.

4. Integrate Slack and Telegram

Browser notifications won’t wake anyone up. Connect at least one mobile chat channel:

  • Telegram: Message @BotFather, run /newbot, and copy the Bot Token. Paste it under Settings > ChatOps > Telegram in Grafana OnCall and save. Each engineer then links their Telegram handle in their OnCall user profile to receive direct alerts.
  • Slack: Open Settings > ChatOps > Slack and run the one-click Slack App manifest wizard. Your DOMAIN must be reachable over HTTPS (via Nginx, Caddy, or a Cloudflare Tunnel) for Slack callbacks to work. Once linked, engineers get interactive Acknowledge and Resolve buttons inside Slack.

5. Test with a Simulated 2 AM Alert

Never trust an alerting pipeline you haven’t fired yourself. Create a new Webhook integration under OnCall > Integrations, attach it to Critical Prod Escalation, and copy the generated URL. Fire a test payload from your terminal:

curl -X POST "http://localhost:8080/integrations/v1/webhook/YOUR_TOKEN_HERE/" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "[CRITICAL] PostgreSQL connection pool exhausted",
    "message": "prod-db-01 active connections at 100% (200/200). API returning 502s.",
    "state": "alerting"
  }'

Your OnCall dashboard should show a new alert group within 2 to 5 seconds, followed by a Telegram or Slack ping. Click Acknowledge to confirm the 5-minute escalation timer cancels cleanly.

Production Checklist: Sleeping Better After 2 AM

You now have a self-hosted incident router with schedules, alert deduplication, and mobile escalations. Small DevOps teams get the same operational discipline as enterprise SaaS tools without the per-seat tax.

Two caveats matter before you trust this stack with real production traffic. First, switch DATABASE_TYPE from SQLite to PostgreSQL or MySQL—SQLite file locking between the engine and celery containers becomes a bottleneck once alert volume climbs. Second, point an external uptime monitor (like Uptime Kuma on a separate host, or Healthchecks.io) at your Docker server. If your monitoring host dies at 2 AM, an outside probe needs to tell you first.

Share: