Categorygithub.com/kumina/postfix_exporter
modulepackage
0.0.0-20221013165341-a6f58e9b2b2b
Repository: https://github.com/kumina/postfix_exporter.git
Documentation: pkg.go.dev

# README

Prometheus Postfix exporter

Prometheus metrics exporter for the Postfix mail server. This exporter provides histogram metrics for the size and age of messages stored in the mail queue. It extracts these metrics from Postfix by connecting to a UNIX socket under /var/spool. It also counts events by parsing Postfix's log entries, using regular expression matching. The log entries are retrieved from the systemd journal, the Docker logs, or from a log file.

Options

These options can be used when starting the postfix_exporter

FlagDescriptionDefault
--web.listen-addressAddress to listen on for web interface and telemetry9154
--web.telemetry-pathPath under which to expose metrics/metrics
--postfix.showq_pathPath at which Postfix places its showq socket/var/spool/postfix/public/showq
--postfix.logfile_pathPath where Postfix writes log entries/var/log/mail.log
--log.unsupportedLog all unsupported linesfalse
--docker.enableRead from the Docker logs instead of a filefalse
--docker.container.idThe container to read Docker logs frompostfix
--systemd.enableRead from the systemd journal instead of filefalse
--systemd.unitName of the Postfix systemd unitpostfix.service
--systemd.sliceName of the Postfix systemd slice.""
--systemd.journal_pathPath to the systemd journal""

Events from Docker

Postfix servers running in a Docker container can be monitored using the --docker.enable flag. The default container ID is postfix, but can be customized with the --docker.container.id flag.

The default is to connect to the local Docker, but this can be customized using the DOCKER_HOST and similar environment variables.

Events from log file

The log file is tailed when processed. Rotating the log files while the exporter is running is OK. The path to the log file is specified with the --postfix.logfile_path flag.

Events from systemd

Retrieval from the systemd journal is enabled with the --systemd.enable flag. This overrides the log file setting. It is possible to specify the unit (with --systemd.unit) or slice (with --systemd.slice). Additionally, it is possible to read the journal from a directory with the --systemd.journal_path flag.

Build options

Default the exporter is build with systemd journal functionality (but it is disabled at default). Because the systemd headers are required for building with systemd, there is an option to build the exporter without systemd. Use the build tag nosystemd.

go build -tags nosystemd

# Packages

No description provided by the author

# Functions

CollectBinaryShowqFromReader parses Postfix's binary showq format.
CollectShowqFromReader parses the output of Postfix's 'showq' command and turns it into metrics.
CollectShowqFromSocket collects Postfix queue statistics from a socket.
CollectTextualShowqFromReader parses Postfix's textual showq output.
No description provided by the author
InitLogSourceFactories runs Init on all factories.
NewDockerLogSource returns a log source for reading Docker logs.
NewFileLogSource creates a new log source, tailing the given file.
NewLogSourceFromFactories iterates through the factories and attempts to instantiate a log source.
NewPostfixExporter creates a new Postfix exporter instance.
NewSystemdLogSource returns a log source for reading Systemd journal entries.
RegisterLogSourceFactory can be called from module `init` functions to register factories.
ScanNullTerminatedEntries is a splitting function for bufio.Scanner to split entries by null bytes.

# Structs

A DockerLogSource reads log records from the given Docker journal.
A FileLogSource can read lines from a file.
PostfixExporter holds the state that should be preserved by the Postfix Prometheus metrics exporter across scrapes.
A SystemdLogSource reads log records from the given Systemd journal.

# Interfaces

A DockerClient is the client interface that client.Client provides.
A LogSource is an interface to read log lines.
No description provided by the author
A LogSourceFactory provides a repository of log sources that can be instantiated from command line flags.
A SystemdJournal is the journal interface that sdjournal.Journal provides.