FALVARIX
FALVARIX
devops --real --no-hype

Prometheus & Grafana: Critical Alerts to Slack & Telegram

Prometheus & Grafana: Critical Alerts to Slack & Telegram

Prometheus & Grafana: Critical Alerts to Slack & Telegram

It’s 3:12 in the morning and your phone buzzes. It’s not a real incident: it’s the fortieth alert this week telling you a disk is at 71%. Two hours later, when the database actually goes down, the notification gets lost in the noise and nobody sees it until a customer emails.

This isn’t a tools problem — it’s a design problem. A good Prometheus and Grafana stack doesn’t measure everything: it tells you only about what requires human action, and it does so in the channel you actually watch. In this guide we’ll set up the full stack with Docker Compose, write rules worth waking someone up for, and route critical alerts to Slack or Telegram with Alertmanager.

Why most monitoring setups fall short

Three failures show up in almost every team.

  • Alerting on causes, not symptoms. A CPU at 90% isn’t an incident if requests still respond in 80 ms. A 5% error rate is, even if the CPU is idle.
  • Everything lands in the same channel. When informational notices and real outages sit side by side, the brain learns to ignore them all.
  • Alerts with no owner and no context. A message that says “HighLoad” doesn’t explain which service, what the impact is, or what to do first.

The fix is a simple rule: if an alert doesn’t require someone to do something right now, it’s not an alert — it’s a dashboard.

Stack architecture

Each piece has a clear job:

  • Prometheus scrapes metrics, stores them as time series, and evaluates alert rules.
  • Exporters (node_exporter, cAdvisor, blackbox_exporter) expose metrics from servers, containers, and endpoints.
  • Alertmanager receives alerts from Prometheus, groups them, deduplicates, silences, and routes them.
  • Grafana visualizes data and is for investigating, not for alerting.

That separation matters: Prometheus decides when there’s a problem, and Alertmanager decides who gets told and how. If you blur both responsibilities into Grafana, you end up with scattered rules that are hard to version.

Quick deploy with Docker Compose

This docker-compose.yml brings up the core of the stack with persistent volumes:

services:
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus:/etc/prometheus
      - prom_data:/prometheus
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.retention.time=30d
    ports: ["9090:9090"]

  alertmanager:
    image: prom/alertmanager:latest
    volumes:
      - ./alertmanager:/etc/alertmanager
    ports: ["9093:9093"]

  node_exporter:
    image: prom/node-exporter:latest
    pid: host
    volumes:
      - /:/host:ro,rslave
    command: ["--path.rootfs=/host"]

  grafana:
    image: grafana/grafana:latest
    volumes:
      - grafana_data:/var/lib/grafana
    ports: ["3000:3000"]

volumes:
  prom_data:
  grafana_data:

In production, pin exact versions instead of using latest, and don’t expose ports directly. The sensible move is to put Grafana behind a TLS proxy; our guide to Traefik in Docker with automatic SSL shows you the easiest way to do it.

Prometheus configuration

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - /etc/prometheus/rules/*.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets: ["alertmanager:9093"]

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: nodes
    static_configs:
      - targets: ["node_exporter:9100"]

A 15-second interval gives you enough resolution to catch outages without blowing up storage use. Once you have dozens of servers, managing static_configs by hand becomes unworkable. Deploy exporters through automation — for example with the approach in Ansible for hardening Linux servers — and move to file- or DNS-based service discovery.

Alert rules worth waking someone up for

Create prometheus/rules/critical.yml. Every rule includes a for duration to avoid false positives and useful annotations for whoever receives it.

groups:
  - name: criticas
    rules:
      - alert: InstanciaCaida
        expr: up == 0
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "{{ $labels.instance }} no responde"
          description: "El job {{ $labels.job }} lleva 2 minutos caído."

      - alert: DiscoPorLlenarse
        expr: predict_linear(node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"}[6h], 4*3600) < 0
        for: 15m
        labels:
          severity: critical
        annotations:
          summary: "Disco lleno en menos de 4 h en {{ $labels.instance }}"

      - alert: MemoriaAgotada
        expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.05
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Menos del 5 % de RAM libre en {{ $labels.instance }}"

Predict instead of react

Take a look at DiscoPorLlenarse. Rather than alerting when only 10% of space is left, use predict_linear to estimate whether the disk will fill up in the next four hours. A disk at 85% growing slowly doesn’t bother anyone. One at 60% filling up fast because of a runaway log deserves immediate attention. To clean up those cases preemptively, you can lean on defensive Bash scripts for backups and disks.

Two severity levels are enough

Define only critical and warning. Critical interrupts a person; everything else piles up in a quiet channel to review during working hours. More levels just spark debates and don’t change anyone’s behavior.

Alertmanager: routing to Slack and Telegram

This is where the stack goes from decorative to useful. Alertmanager has always supported Slack, and Telegram natively since version 0.24.

Slack with an incoming webhook

Create an app in Slack, enable Incoming Webhooks, and generate one URL per channel. Store that URL in a file, not in the YAML:

route:
  receiver: slack-avisos
  group_by: [alertname, instance]
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  routes:
    - matchers: [severity="critical"]
      receiver: critico
      repeat_interval: 1h

receivers:
  - name: slack-avisos
    slack_configs:
      - api_url_file: /etc/alertmanager/secrets/slack_avisos
        channel: "#monitoreo"
        send_resolved: true
  - name: critico
    slack_configs:
      - api_url_file: /etc/alertmanager/secrets/slack_critico
        channel: "#incidentes"
        send_resolved: true
        title: "🔥 {{ .CommonAnnotations.summary }}"
        text: "{{ .CommonAnnotations.description }}"

Telegram with your own bot

Talk to @BotFather in Telegram to create the bot and get its token. Add the bot to a group and fetch the chat_id via the getUpdates API. Groups have negative IDs.

receivers:
  - name: critico
    telegram_configs:
      - bot_token_file: /etc/alertmanager/secrets/telegram_token
        chat_id: -1001234567890
        parse_mode: HTML
        send_resolved: true
        message: |
          🚨 <b>{{ .CommonLabels.alertname }}</b>
          {{ .CommonAnnotations.summary }}
          <i>{{ .CommonAnnotations.description }}</i>

Telegram is great for small teams or personal on-call, because the notification arrives with high priority and works even with your phone in focus mode — as long as you allow that chat. Slack fits better when several people need to collaborate on the incident in a thread. Nothing stops you from combining both: Slack for the history, Telegram for critical on-call.

Grouping, inhibition, and silences

Three mechanisms separate a usable system from one that drowns you:

  1. Grouping: group_by saves you from 30 messages when a server with 30 services goes down — you get just one.
  2. Inhibition: if a node is down, suppress the alerts derived from that node.
  3. Silences: during scheduled maintenance, create a silence from the Alertmanager UI with automatic expiry.
inhibit_rules:
  - source_matchers: [alertname="InstanciaCaida"]
    target_matchers: [severity="warning"]
    equal: [instance]

Grafana: dashboards for investigating, not for decoration

Connect Prometheus as a data source in http://prometheus:9090. Start by importing the Node Exporter Full community dashboard (ID 1860), then build your own with a single health screen.

A useful status panel answers three questions in five seconds: is everything up? are there errors? how much headroom is left? We recommend including:

  • up status of all jobs in a traffic-light format.
  • Error rate and p95 latency for your services.
  • Disk usage with the four-hour prediction.
  • Active alerts, via the Alert list panel.

Use file-based provisioning (/etc/grafana/provisioning) to version data sources and dashboards in Git. That way you rebuild the whole environment in minutes and changes go through review, just like in a GitOps workflow with ArgoCD.

Security and operating the stack

A leaky monitoring system is a map of your infrastructure for an attacker. Before calling it done:

  • Protect your secrets. Telegram tokens and Slack webhooks belong in a vault, not in the repo. If you haven’t sorted that out yet, see how to manage secrets with OpenBao.
  • Don’t expose Prometheus or Alertmanager to the internet. They have no native authentication; use an internal network, an authenticating proxy, or a VPN.
  • Enable authentication in Grafana, change the default password, and consider SSO.
  • Monitor the monitor. Set up a “dead man’s switch” alert with vector(1) that always fires to an external heartbeat service: if it stops arriving, your Alertmanager is dead.
  • Set retention and backups. Thirty days is usually enough; for long-term history, consider remote storage like Thanos or Mimir.

Common mistakes to avoid

Forgetting for. Without a minimum duration, a 15-second spike fires a critical alert at 3 a.m.

Alerting on metrics without context. If the message doesn’t say what to do, add an annotation runbook_url pointing to a runbook.

Not testing the channel. Fire a test alert with amtool alert add or via the Alertmanager API before you depend on it. Also confirm the resolution message arrives.

Creating one alert per metric. Start with five well-thought-out critical alerts and only add more after a real incident that slipped through.

When the stack matures: next steps

Once your metrics are stable, the next leap is correlating them with logs. If you want to analyze them without sending data to third parties, check out how to set up a logs copilot with local, 100% private AI. Prometheus tells you what is broken; logs tell you why.

Conclusion

Monitoring that works isn’t measured by the number of metrics collected, but by the quality of decisions it enables. With Prometheus detecting real symptoms, Alertmanager filtering out the noise, and Slack or Telegram delivering the notice to the right channel, your team sleeps better and reacts faster when it actually matters.

Start small: bring up the stack, define three critical alerts, deliberately trigger them, and tune after every incident. In a month you’ll have a system tuned to your infrastructure — not a generic template.

Keep reading