User Tools

Site Tools


development:applications:prometheus-smtp-exporter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:applications:prometheus-smtp-exporter [2017/12/05 12:03] adsilvadevelopment:applications:prometheus-smtp-exporter [2021/06/25 10:09] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Prometheus SMTP Exporter ======
 +
 +We use [[https://github.com/cherti/mailexporter|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: [[https://github.com/cherti/mailexporter#building-and-running|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:
 +
 +<code>
 +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
 +</code>
 +
 +
 +====== Mailexporter configuration ======
 +
 +By defaut, mailexporter reads /etc/mailexporter.conf as its configfile. This can be changed via the command line flag -config-file.
 +
 +<code yaml>
 +# 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
 +</code>
 +====== Prometheus Configuration ======
 +
 +Once mailexporter is running and it is confirmed that the endpoint is available, we can configure Prometheus as follows:
 +
 +<code yaml>
 +  - job_name: 'SMTP stats'
 +    scrape_interval: 5m
 +    static_configs:
 +      - targets:
 +        - 'S.E.R.V.E.R.I.P:PORT'  
 +</code>
 +
 +For more information on how to setup your own rules in the Errigal environment, 
 +refer: [[https://bitbucket.org/errigal/prometheus-monitoring-config|prometheus-monitoring-config]]