To monitor Postfix SMTP performance, combine mail-server metrics with dashboards and alerts. Prometheus collects measurements over time, while Grafana turns them into readable graphs. This setup helps you spot growing queues, delayed delivery, and authentication attacks before they affect customers.
Why Monitor Postfix SMTP Performance?
Postfix logs show individual delivery events, but they are harder to compare across hours or days. A monitoring system reveals trends in queued messages, delivery delays, deferrals, rejections, and failed logins. Add Linux CPU, memory, and disk metrics to distinguish a mail problem from resource exhaustion.
Step 1: Check Your Mail Server Baseline
Start on a working Linux VPS with Postfix and secure access. Check queue status and recent mail events:
sudo postqueue -p
sudo journalctl -u postfix --since '1 hour ago'
On systems using /var/log/mail.log, inspect that file instead. Record normal queue size and delivery patterns before setting alert thresholds.
Step 2: Export Postfix Metrics
Install a maintained Postfix Prometheus exporter from a reviewed package or its source. The Postfix exporter documentation describes queue statistics from the showq socket and delivery events from logs.
After installing its binary, a local file-log configuration can use:
postfix_exporter \
--web.listen-address=127.0.0.1:9154 \
--postfix.showq_path=/var/spool/postfix/public/showq \
--postfix.logfile_path=/var/log/mail.log
Alternatively, use --systemd.enable where Postfix events are available in the journal. Grant only the socket and log access the exporter requires. Test http://127.0.0.1:9154/metrics locally, then run it under a managed service account.
Step 3: Configure Prometheus Scraping
When Prometheus runs on the same VPS, add this job to the existing scrape_configs section of prometheus.yml:
- job_name: postfix
scrape_interval: 15s
static_configs:
- targets: ['127.0.0.1:9154']
Validate and reload Prometheus. Check Status → Targets for an UP Postfix job. If Prometheus is remote, use a private network endpoint instead of localhost. Never expose metrics publicly without access controls.
Step 4: Build a Grafana Mail Dashboard
In Grafana, add the Prometheus data source and select your server. Start with two PromQL queries:
up{job="postfix"}
rate(postfix_smtp_deferred_messages_total[5m])
The first checks exporter availability. The second estimates the rate of SMTP deferrals. Also chart queue age, rejections, and SASL authentication failures using metric names actually exposed by your exporter. Add Node Exporter for disk and memory trends.
Step 5: Set Alerts and Verify Results
Alert on a down exporter, sustained deferrals, unusually old messages, and low free disk space. Test a controlled delivery failure and confirm the graph changes. Compare dashboard values with Postfix logs; exporters can miss events if log permissions or parsing fail.
For self-managed hosting, CybroHost SMTP VPS Hosting offers root access and server control for monitoring tools.
FAQs
Does Grafana replace Postfix logs?
No. Grafana summarizes metrics; logs explain individual delivery errors.
Can Prometheus confirm inbox delivery?
No. SMTP acceptance does not prove a message reached the inbox.
Does monitoring slow down my SMTP VPS?
It adds some resource usage. Choose sensible scrape intervals, retention limits, and dashboard queries.
Final Recommendation
Track Postfix queues, deferrals, authentication failures, and server health together. Start with a few useful alerts and adjust thresholds using real traffic patterns.
