User Tools

Site Tools


Writing /app/www/public/data/meta/development/applications/prometheus-smtp-exporter.meta failed
development:applications:prometheus-smtp-exporter

Prometheus SMTP Exporter

We use mailexporter as a Prometheus exporter for SMTP server metrics.

mailexporter is a platform specific binary which must be built and deployed on the server where SMTP is running. It basically provides an HTTP endpoint with all the statistics related to the SMTP server. This end point is fetched/requested by Prometheus on a periodic basis.

For more information on how to build mailexporter, refer: mailexporter

The set up is very straight forward,

After building the appropriate binary, place it in an appropriate directory. usually “/usr/local/bin”

Note: The binaries are not cross-platform compatible. Either build it on the same machine where you want to run the exporter or add a cross-compile directive when building it locally.

Building it locally for linux, will look something like this:

brew install golang
mkdir ~/go && export GOPATH=$HOME/go
go get github.com/cherti/mailexporter
cd ~/go/src/github.com/cherti/mailexporter
go get ./...
env GOOS=linux GOARCH=amd64 go build mailexporter.go

Mailexporter configuration

By defaut, mailexporter reads /etc/mailexporter.conf as its configfile. This can be changed via the command line flag -config-file.

# time between two monitoring-attempts
monitoringinterval: 10m
 
# Time until mail must have arrived after sending for positive outcome
mailchecktimeout: 3m

servers:
    - name: localhost                     # name for internal prometheus-metric
      server: localhost                   # SMTP-server to use
      port: 587                           # port to use on Server for SMTP
      login: monitoring                   # login name on server (leave empty together with passphrase to disable authentication)
      passphrase: 123password             # SMTP-login-password (leave empty together with login to disable authentication)
      from: monitoring@helper1.com        # From-Header of monitoring-Mail (e.g. for filtering)
      to: monitoring@example.com          # address to deliver to
      detectiondir: /home/me/Maildir/new  # Maildir in which to look for monitoring-mail

Prometheus Configuration

Once mailexporter is running and it is confirmed that the endpoint is available, we can configure Prometheus as follows:

  - job_name: 'SMTP stats'
    scrape_interval: 5m
    static_configs:
      - targets:
        - 'S.E.R.V.E.R.I.P:PORT'  

For more information on how to setup your own rules in the Errigal environment, refer: prometheus-monitoring-config

development/applications/prometheus-smtp-exporter.txt · Last modified: 2021/06/25 10:09 by 127.0.0.1