Last updated

Homelab

Monitor Mailcow With Prometheus and Grafana

Watch your Mailcow mail server's health with Prometheus and Grafana: container and host metrics, mail queue size and disk space, with alerts before users notice a problem. This is the quick overview; the full guide has every config file.

Related guide: Full Mailcow monitoring guide

1. Collect host and container metrics

Run node_exporter for the host and cAdvisor for the Docker containers on the Mailcow server, listening on localhost or a private network only.

docker run -d --name node_exporter --net=host --pid=host -v /:/host:ro,rslave quay.io/prometheus/node-exporter:latest --path.rootfs=/host

docker run -d --name cadvisor -p 8080:8080 -v /:/rootfs:ro -v /var/run:/var/run:ro -v /sys:/sys:ro -v /var/lib/docker/:/var/lib/docker:ro gcr.io/cadvisor/cadvisor:latest

2. Point Prometheus at them

Add scrape jobs to prometheus.yml on your monitoring server, then reload Prometheus.

scrape_configs:
  - job_name: mailcow-node
    static_configs:
      - targets: ['mail.example.com:9100']
  - job_name: mailcow-containers
    static_configs:
      - targets: ['mail.example.com:8080']

3. Add Grafana

Run Grafana, add Prometheus as a data source and import a Node Exporter dashboard.

docker run -d --name grafana -p 3000:3000 grafana/grafana

4. What to watch

These catch most mail outages early.

MetricWhy it matters
Disk used on /var/lib/dockerFull disks stop mail delivery
Container restartspostfix, dovecot or rspamd crash loops
Postfix queue size (Mailcow UI or a postfix exporter)Mail stuck and not leaving
Memory and swaprspamd and clamd use a lot of RAM
Certificate expiryExpired TLS breaks mail clients

5. Set alerts

Use Grafana alerting or Alertmanager to email or message you, for example when disk use passes 85% or the mail queue keeps growing.

FAQ

Do I need to expose exporters to the internet?

No. Keep exporter ports on a private network or VPN, or allow them only from your Prometheus server's IP.

Does Mailcow have built-in monitoring?

The Mailcow UI shows container status and the mail queue, but it does not keep history or send alerts. Prometheus and Grafana add both.