Monitoring Postfix
Postfix is recognised by its master process together with the installed postfix package,
and the probes start on their own within a minute. Nothing is configured on your side: the
version comes from postconf, the queue from postqueue, and delivery outcomes from the
log Postfix already writes.
How Postfix is recognised
Three signed definitions cover the three init systems, and they differ only in where the
mail log lives. All of them require a running process named master and the postfix
package (the process name alone is too common to trust). The systemd variant reads delivery
outcomes from the journal, the OpenRC variant tails /var/log/messages, the sysvinit
variant tails /var/log/mail.log. On the two file variants a missing log is not an error:
the check reports ok and the tailer starts the moment the file appears.
Once matched, the agent runs postconf mail_version for the version fact, and every 60
seconds it dials port 25, runs postqueue -p and counts the log lines written since its
last pass. The Postfix inside Proxmox Mail Gateway matches this definition too.
What is collected
Queue. postqueue -p ends with a summary of the queue; the agent takes the number of
queued messages and their size in kilobytes from it.
Delivery outcomes. The lines written by the delivery agents (smtp, lmtp, local,
virtual, pipe, error) carry a status= field. The agent counts status=sent,
status=deferred and status=bounced into three per-second rates. Only new lines are
read, from a saved position; this probe stores nothing about individual messages.
Port 25. A connection to 127.0.0.1:25 has to be accepted. This check deserves a
sentence of its own, because Postfix can be half broken: mail submitted locally enters
through pickup and leaves through the smtp client, so a box whose smtpd is
misconfigured keeps sending while nothing can be delivered to it. The sent rate stays
healthy and the port check fails. Since master still holds the socket, the failure reads
"the port is bound but the service is not accepting connections", which is a different
message from a closed port and points straight at smtpd.
Facts shown on the host page: the Postfix version.
| Signal | Metric |
|---|---|
| Queued messages | svc.postfix.queue_requests |
| Queue size in KB | svc.postfix.queue_kbytes |
| Delivered per second | svc.postfix.sent_rate |
| Deferred per second | svc.postfix.deferred_rate |
| Bounced per second | svc.postfix.bounced_rate |
Names, tags and units are in the metrics reference.
Logs. The journal entries of the Postfix daemons (smtpd, qmgr, cleanup, pickup,
bounce, postscreen, tlsmgr and the rest) ship at notice level and above, so warnings
and fatal errors arrive while the per-message chatter stays on the host. On Proxmox Mail
Gateway, where Postfix logs to a file, /var/log/mail.log is read instead and only lines
marked fatal, error, warning or panic ship. See Logs.
Alerts out of the box
| Rule | Fires when | Severity | Ships |
|---|---|---|---|
| Mail queue backlog | 200 or more queued messages for 15 minutes | warning | on |
| Mail bounce storm | half a bounce per second or more, sustained for 15 minutes | warning | on |
| Outgoing mail keeps getting deferred | a tenth of a deferral per second or more (six a minute), sustained for 15 minutes | warning | auto |
Retries are part of normal mail: a greylisting peer or a slow remote parks messages for a while and they drain on their own, so the backlog rule waits fifteen minutes and closes only once the queue is back under 100. Half a bounce per second is thirty a minute, kept up for a quarter of an hour; a mistyped address does not do that, a list full of dead recipients or a spammer relaying through you does. The deferral rule arms itself once the mail log flows and catches the quieter failure: a relay that rejects you, a DNS problem or a full disk on the other side parks every message as deferred without a single bounce, and six deferrals a minute kept up for a quarter of an hour is that, not greylisting. Thresholds and hysteresis for each rule are in the rules catalog.
Limitations
- Only port 25 is probed. Submission on 587 or 465 is not checked.
- The queue figures are parsed from the summary line
postqueue -pprints. An empty queue prints no summary, so the queue metrics have no point for that minute rather than a zero. - On systemd hosts the delivery rates come from the journal. If your syslog setup keeps Postfix out of the journal, the rates stay empty while the queue and port checks keep working.
- On OpenRC and sysvinit the log path is fixed (
/var/log/messagesand/var/log/mail.log) and there is no override key for Postfix, so a mail log kept elsewhere yields no rates. - Rates are totals across all domains and recipients; there is no per-domain breakdown and no per-message detail.
Related
- Monitoring Dovecot, Monitoring Exim
- Monitoring Proxmox Mail Gateway, whose own Postfix is covered by this page
- Mail server monitoring on the main site