Giter VIP home page Giter VIP logo

postfix_exporter's Introduction

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

Flag Description Default
--web.listen-address Address to listen on for web interface and telemetry 9154
--web.telemetry-path Path under which to expose metrics /metrics
--postfix.showq_path Path at which Postfix places its showq socket /var/spool/postfix/public/showq
--postfix.logfile_path Path where Postfix writes log entries /var/log/mail.log
--log.unsupported Log all unsupported lines false
--docker.enable Read from the Docker logs instead of a file false
--docker.container.id The container to read Docker logs from postfix
--systemd.enable Read from the systemd journal instead of file false
--systemd.unit Name of the Postfix systemd unit postfix.service
--systemd.slice Name of the Postfix systemd slice. ""
--systemd.journal_path Path 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

postfix_exporter's People

Contributors

aponert avatar azanx avatar bartverc avatar corny avatar eklitzke avatar evilham avatar flyhard avatar ivaylo-korakov avatar jangrewe avatar k-kinzal avatar liwo avatar martinkoerper avatar mjtrangoni avatar paradis avatar piotr1212 avatar silkeh avatar timstoop avatar tommie avatar willibutz avatar ylecuyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postfix_exporter's Issues

Feature request: Switch to kingpin

Hi,

Prometheus and many exporters are switching to kingpin. See also prometheus#2455. You will have to do some prometheus vendoring updates, but it should work as a drop-in replacement.

Thanks!

Commit 8e63fbbe omits 13 output types for those using systemd.enable & null logfile_path

I installed postfix_exporter compiled from the latest version sha 8e63fbbe and found that data stopped updating in several windows of the anarcat Postfix dashboard.

I compiled a couple of back revisions and ran them manually as follows:

sudo -u postfix /usr/local/bin/tmp/postfix_exporter.01.8e63fbb --systemd.enable --postfix.logfile_path=
sudo -u postfix /usr/local/bin/tmp/postfix_exporter.02.bbcbead --systemd.enable --postfix.logfile_path=

Comparing the output (with values removed) from 8e63fbb and bbcbead, I found these values missing:

% diff -uwb out.01.8e63fbb out.02.bbcbead | grep ^\+\#\ TYPE
+# TYPE postfix_cleanup_messages_not_accepted_total
+# TYPE postfix_cleanup_messages_processed_total
+# TYPE postfix_cleanup_messages_rejected_total
+# TYPE postfix_qmgr_messages_inserted_receipients
+# TYPE postfix_qmgr_messages_inserted_size_bytes
+# TYPE postfix_qmgr_messages_removed_total
+# TYPE postfix_smtp_connection_timed_out_total
+# TYPE postfix_smtp_deferred_messages_total
+# TYPE postfix_smtp_status_deferred
+# TYPE postfix_smtpd_connects_total
+# TYPE postfix_smtpd_disconnects_total
+# TYPE postfix_smtpd_forward_confirmed_reverse_dns_errors_total
+# TYPE postfix_smtpd_sasl_authentication_failures_total

I'd suspect a premature return in @k-kinzal 's pull request

undefined: prometheus.Handler

Dears,

I'm trying build binary:

$ go build -tags nosystemd

But I have the follow error

~/git/puppet/postfix_exporter
./postfix_exporter.go:694:28: undefined: prometheus.Handler

How could I solve it ?

Support for multiple instances

Is there a suggested way of supporting multiple postfix instances on one host?
Currently it seems I'd need a separate postfix_exporter for each postfix instance, and have to add the instance name in Prometheus scrape configuration.

TLS 1.3 log lines not parsed

Current regex does not parse TLSv1.3 connections.

Log line example:
Nov 08 10:07:48 mx-3 postfix/smtpd[323791]: Trusted TLS connection established from mx-1..[192.168.1.1]:38929: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256

Regex for smtpd does not expect this format because log line has text after "with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)".

Regex smtpdTLSLine (0.3, 0.2 versions):
smtpdTLSLine = regexp.MustCompile(^(\S+) TLS connection established from \S+: (\S+) with cipher (\S+) \((\d+)/(\d+) bits\)$)

Same things for smtp.
BTW, thanks for exporter!

journald metrics not available

When running postfix_exporter built from master, journald metrics are not available, and there is only a single path for the postfix_up metric present when querying the exporter.
The exporter is printing "Reading log events from systemd" on startup.

Bisecting with git reveals that commit 26d0642 introduced the issue.

Support for submission/smtpd

It is a common practice to implement a smtpd on port 587 for the submission service. The naming is defined from the configuration on the master.cf

for example

submission inet n       -       -       -       -       smtpd
  -o syslog_name=postfix/submission

produces the log

Απρ 15 12:20:28 mx2 postfix/submission/smtpd[6833]: Anonymous TLS connection established from  xx[5.5.5.5]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)

These could be reported along with smtpd or in a seperate submission prefix.

Help installing Postfix Exporter

Please, i need help to install Prometheus Postfix Exporter

My services are:
1 server Ubuntu 18.04: Prometheus - Grafana
1 server Debian 8.11: Postfix - Dovecot - Roundcube

I don't understand how I can install it

Does sometimes not pick up rotated logs

According to the readme: Rotating the log files while the exporter is running is OK. While this works most of the times, it already happened twice in two days that it does not and the exporter keeps tracking deleted files.


postfix+ 18282     1  0 May11 ?        00:07:50 /usr/local/bin/postfix_exporter --postfix.logfile_path=/var/log/mail.log

ls -l /proc/18282/fd/
total 0
<< skipped >>
lr-x------ 1 postfix-exporter postfix-exporter 64 May 11 11:55 3 -> '/var/log/mail.log.1 (deleted)'

rotate config:

/var/log/mail.log
{
        rotate 24
        hourly
        missingok
        notifempty
        compress
        delaycompress
        sharedscripts
        maxsize 200M
        postrotate
                /usr/lib/rsyslog/rsyslog-rotate
        endscript
}

OS: Ubuntu 18.04 LTS

Running latest commit b050cdf

BTW could not get journald log working at all, probably related to #55

Truncating logfiles is really bad...

Instead, processed log entries should at least be written to a separate file which holds all already processed log entries.

A better approach would be to save a pointer somewhere and save the last read position of the logfile. Then fseek to it and go on reading.
If logrotate or something else is in place, you can also save a hash value of the first line in the file. Since logfiles are append only you can reliably determine, if a logfile is all new and never read so you can start reading it from the beginning.

Truncating is the worst since it destroys all log data. Prometheus metrics are no substitution for that.

undefined: Journal

Trying to run exporter I have this error:

go run postfix_exporter.go --postfix.logfile_path=la.log
./postfix_exporter.go:48:13: undefined: Journal

smtpTLSLine doesn't match

Hi there! Thanks for your work on this.

I noticed that in my setup, I'm getting no data points for outgoing TLS connections. I think I traced this down:

postfix/smtp[14659]: Verified TLS connection established to gmail-smtp-in.l.google.com[2a00:1450:4010:c0f::1b]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256

This is a log line from my postfix. If I'm reading the code right, that is expected to be matched by the regex in this line:
https://github.com/kumina/postfix_exporter/blob/master/postfix_exporter.go#L280

However, the log line has extra stuf after the (256/256 bits), and while the regex expects it to end there "$". I guess there should there be an extra \S* there?

I'm on postfix 3.4.5-1

List of postfix_smtpd_messages_processed_total growing over time

Hello,

Version: commit af6943b

The list of sasl can grow by a lot for the metric postfix_smtpd_messages_processed_total (in my case > 35000 entries after about a week). This takes up more memory at exporter side, and an increased number of points scrapped at prometheus side.

I think it could be useful to purge the list regularly. As of right now, a workaround in my case can be handled by the systemd unit file with the option RuntimeMaxSec.

Regards,
Mike

Install is stuck

Just trying to install got this error

# github.com/coreos/go-systemd/v22/sdjournal
../go/pkg/mod/github.com/coreos/go-systemd/[email protected]/sdjournal/journal.go:27:11: fatal error: systemd/sd-journal.h: No such file or directory
 // #include <systemd/sd-journal.h>
           ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Referenced file, systemd/sd-journal.h, seems doesn't exist anymore. Any clue?

Provide a release built with `-nosystemd`

It would be nice if the release contained both a binary built for use with systemd and one built for use without systemd. I imagine you could just call the non-systemd binary postfix_exporter-nosystemd.

Question about using exporter in kubernetes

Hi!

I want to use this exporter in kubernetes. But postfix in kubernetes write log to /dev/stdout.
If I try to use --postfix.logfile_path="/dev/stdout" - I have error:

2020/10/15 08:03:33 Reading log events from "/dev/stdout"
2020/10/15 08:03:33 Failed to create PostfixExporter: open "/dev/stdout": no such file or directory

How I can disable to use postfix log files from this exporter? And will it work correctly after that?
I only need to read the size of the postfix queues.

Thanks.

misleading metric names

hi there,

postfix_showq_message_size_bytes_count -> shows the count of messages in the queue and has nothing to do with either size nor bytes

you might want to rename that metric name

Confusion around metrics

I've been looking at the 'postfix_showq_message_size_bytes_count' metric. I would like to be able to monitor the queue depth for postfix, and this seems to be the most appropriate metric, however, I am not sure if I am grasping what it is trying to express.

It doesn't seem like there is any metric that will count individual messages (that would be a great metric to have), so how exactly should I be using this metric to understand the queue depth with postfix? I've seen a grafana dashboard using this exporter, but that graph doesn't really correspond with the messages we are processing.

Any insight here would be really welcome!

thanks!

Permission denied opening logfile

I have attempted to install prometheus-postfix-exporter as an ubuntu package but I cannot get it to work on 20.04 (permission denied opening the logfile), whereas it does work on another server 22.04 which seems to have the same config.

The documentation doesn't say anything about permissions anywhere but the service is installed as user prometheus which doesn't appear to have any special permissions or be added into any groups. For this reason, the permission denied problem makes sense to me and might simply point to needing some docs to say, "by the way, you have to setup relevant permissions etc." except for the fact that the other server works without these steps!

The docs say that this exporter will truncate the incoming log file which presumably means that the prometheus user needs to have write permissions to the log file. However, this doesn't actually seem to happen, I ran the exporter on the CLI as root and it ran up fine but didn't truncate the logfile (the metrics were all shown on port 9054 as expected)

So as you can see, I have got very confused. Since it does work as root, maybe it is just a permissions issue and maybe it is not actually supposed to truncate the file any more? I got the ubuntu instructions here: https://manpages.ubuntu.com/manpages/focal/man1/prometheus-postfix-exporter.1.html

Thanks

add --version flag

Hey,

it would be nice if we can have a --version flag so we can check the version of the binary on the system.
WIth that information I could execute ansible in an idempotent way so that the binary gets installed, when the version in the ansible playbook differs from the one installed on the system.

Crash with systemd.enable

I built a static binary using build_static.sh:

# ./postfix_exporter -systemd.enable
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x68 pc=0x7f5355db7af2]

runtime stack:
runtime.throw(0xa5ac80, 0x2a)
	/usr/lib/go-1.6/src/runtime/panic.go:547 +0x90
runtime.sigpanic()
	/usr/lib/go-1.6/src/runtime/sigpanic_unix.go:12 +0x5a

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x787660, 0xc820045c90, 0x0)
	/usr/lib/go-1.6/src/runtime/cgocall.go:123 +0x11b fp=0xc820045c40 sp=0xc820045c10
github.com/coreos/go-systemd/sdjournal._Cfunc_my_sd_journal_open(0x7f5355da5ab0, 0xc8200d8650, 0xc800000001, 0x0)
	github.com/coreos/go-systemd/sdjournal/_obj/_cgo_gotypes.go:325 +0x41 fp=0xc820045c90 sp=0xc820045c40
github.com/coreos/go-systemd/sdjournal.NewJournal(0xc8200d8650, 0x0, 0x0)
	/go/src/github.com/coreos/go-systemd/sdjournal/journal.go:414 +0x216 fp=0xc820045d28 sp=0xc820045c90
main.NewJournal(0x9d3af0, 0xf, 0x0, 0x0, 0x0, 0x0, 0xc8200cc8e0, 0x0, 0x0)
	/postfix_exporter/systemd.go:29 +0x301 fp=0xc820045dc0 sp=0xc820045d28
main.main()
	/postfix_exporter/postfix_exporter.go:631 +0x285 fp=0xc820045f50 sp=0xc820045dc0
runtime.main()
	/usr/lib/go-1.6/src/runtime/proc.go:188 +0x2b0 fp=0xc820045fa0 sp=0xc820045f50
runtime.goexit()
	/usr/lib/go-1.6/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820045fa8 sp=0xc820045fa0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/lib/go-1.6/src/runtime/asm_amd64.s:1998 +0x1

metrics from systemd-journal are not updated after a while

When I set up this exporter it seemed to work fine at first, but after a while I noticed that some metrics did not get updated anymore. In particular all metrics that come from the systemd-journal:

grafana visualisation

There were still new log messages coming in from the postfix unit, so I went looking for an issue with the exporter itself. As there were no error messages coming from the exporter, I started to strace it and then added some debug output, to find out what was going on.
After a while I found out that this Next() call kept returning (0, nil) for each consecutive access to the log after some time.

It's still not clear to me why this happens exactly but I 'fixed' it by adding the following to postfix_exporter.go:

@@ -409,6 +409,10 @@ func (e *PostfixExporter) CollectLogfileFromJournal() error {
        e.journal.Lock()
        defer e.journal.Unlock()
 
+       r := e.journal.Wait(time.Duration(1) * time.Second)
+       if r < 0 {
+               log.Print("error while waiting for journal!")
+       }
        for {
                m, c, err := e.journal.NextMessage()
                if err != nil {

I found this in a test of the go-systemd library that is used here.

I'm not sure wether this is an appropriate solution for this or if anyone else even experiences the same issue :)

Additional info:

  • the exporter does not crash, it just keeps serving the (unchanged) metrics
  • metrics from the showq socket are not affected by this and are updated continuously
  • I'm using the tagged version 0.1.0 on Linux 4.15 with systemd 234 and postfix 3.2.5
  • the exporter does not output any error messages at any time
  • as the added Wait() call did fix the issue for me, I assume that it does not have anything to do with postfix itself

Provide builds for ARM

It can be tough to build on some of the SBCs such as Raspberry Pi 1 and Zero due to the CPU and low RAM.

Therefore it would be great to have official builds for armv6l (Raspberry Pi Zero/1), armhf (Raspberry Pi 2/3(?)), and aarch64 available to cover all the options

New release(s)

Hi there - this seems like a very useful tool, can I ask if you have plans to make any updated releases - I see that the code is actively maintained but the last release was in early 2019?!
Thanks in advance

Truncating log files is racy

The current truncating behavior can result in messages being missed if they are appended between the time postfix_exporter hits EOF and the time it calls truncate.

To avoid the race it's probably necessary to rename the old log file, drain it (coordinate with syslogd, read until it stops changing for some period of time and/or messages start appearing in the new file), and finally remove the old file.

It's probably easier to use an external log rotation system than to have postfix_exporter coordinate with syslogd (which might be impossible if they're in separate containers).

Need help

Hi ,
I am very new to Go, i want to install postfix_exporter on CentOS for Prometheus/Grafana monitoring. Could you please help me instructions on how to install with this github project? or please share me authentic postfix_exporter binary.

Appreciate your help.

Thanks,
Mahesh.

shasum files

Kindly supply sha256sums.txt files with the releases, which makes verification of the downloaded archives easier during automated installation. See node_exporter releases as an example.

I can highly recommend the usage of goreleaser for releasing your exporters written in go.

--postfix.logfile_path="/var/log/mail" produces panic: runtime error: invalid memory address or nil pointer dereference

This appears to be similar to #54

logs are stored in /var/log/mail instead of /var/log/maillog, passing new logdir crashes on startup.

build@mail:~/INSTALL/postfix_exporter# ./postfix_exporter --postfix.logfile_path="/var/log/mail"
2020/10/05 00:09:24 Reading log events from /var/log/mail
2020/10/05 00:09:24 Listening on :9154
2020/10/05 00:09:24 Seeked /var/log/mail - &{Offset:0 Whence:2}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x832089]

goroutine 8 [running]:
main.(*PostfixExporter).CollectLogfileFromFile(0xc00016a000, 0x9e5740, 0xc000066700)
/postfix_exporter/postfix_exporter.go:437 +0x149
main.(*PostfixExporter).StartMetricCollection(0xc00016a000, 0x9e5740, 0xc000066700)
/postfix_exporter/postfix_exporter.go:671 +0xfd
created by main.main
/postfix_exporter/main.go:69 +0xecb

Tailing seems broken

I am trying to find out why postfix_exporter is underreporting metrics.

I had postfix_exporter runnning for about a month, and its removed count is not high enough for even a day.

While doing some local debugging I discovered that it seems to read the logfile only when the metrics are requested and at that time it reads only the last couple of lines, not all lines since last time.

I am still trying to create a proper testcase for it, but my test so far is like this:

  • I start postfix_exporter on an empty file
  • I request the /metrics endpoint
  • I append a whole day of logs to the file
    cat maillog >> tailing_maillog
  • I request the /metrics endpoint again

The last request has the same counter unless one of the last lines is a line to be counted.

Docker build issue

Hi here,
the docker images isn't build.

docker build -t postfix_exporter .
Sending build context to Docker daemon  163.3kB
Step 1/11 : FROM golang:1.8
 ---> 0d283eb41a92
Step 2/11 : ADD . /go/src/github.com/kumina/postfix_exporter
 ---> Using cache
 ---> f49562557fac
Step 3/11 : WORKDIR /go/src/github.com/kumina/postfix_exporter
 ---> Using cache
 ---> acb297e116a2
Step 4/11 : RUN apt-get update -qq && apt-get install -qqy   build-essential   libsystemd-dev
 ---> Using cache
 ---> ba9935ecd889
Step 5/11 : RUN go get -v ./...
 ---> Running in 7107ab9f144c
github.com/alecthomas/kingpin (download)
github.com/alecthomas/template (download)
github.com/alecthomas/units (download)
github.com/coreos/go-systemd (download)
github.com/coreos/pkg (download)
github.com/hpcloud/tail (download)
github.com/prometheus/client_golang (download)
github.com/beorn7/perks (download)
github.com/cespare/xxhash (download)
package github.com/cespare/xxhash/v2: cannot find package "github.com/cespare/xxhash/v2" in any of:
	/usr/local/go/src/github.com/cespare/xxhash/v2 (from $GOROOT)
	/go/src/github.com/cespare/xxhash/v2 (from $GOPATH)
github.com/golang/protobuf (download)
github.com/prometheus/client_model (download)
github.com/prometheus/common (download)
github.com/matttproud/golang_protobuf_extensions (download)
github.com/prometheus/procfs (download)
The command '/bin/sh -c go get -v ./...' returned a non-zero code: 1

Doesn't work with recent Postfix versions

While this seems to work with the Postfix version included with CentOS 6 (Postfix 2.6), with more recent versions such as Postfix 3.1 it does not work. In Postfix 2.6, /var/spool/postfix/public/showq spits out mailq-formatted output, but in Postfix 3.1 it's a machine-readable format that looks like this:

queue_nameholdqueue_id9A070A4time1489455573size1018sendertest@[email protected]

I am going to try to develop a patch that can consume both formats, but if someone else beats me to it that's fine too.

Unable to scrape socket

Hi,

I tried using this exporter and it started fine as a daemon. However, when it tried to scrape the showq scoket, it returns a permission denied error.

/var/spool/postfix/public is owned by postfix:root and showq is owned by postfix:postfix.

I have tried running the daemon as postfix user and that worked. I tried giving postfix-exporter sudoers access but that still returns the permission error to access showq.

image

Regex SASL AuthenticationFailure Failed

Hi,

Thanks for this great exporter.

We use it for get metrics of postfix server. We use postfix 3.4.13.

We have SASL authentication error in postfix server and it seems that the regex for capture SASL authentication failure doesn't works.

In fact, the regex rules is here https://github.com/kumina/postfix_exporter/blob/master/postfix_exporter.go#L299 this regex use ^warning and we have not this warning string in our smtp log.

Jun 08 14:39:03 myserver postfix/smtp[2107]: 837B04772D24: to=<[email protected]>, relay=mail.server.fr[IpAddress]:25, delay=1088, delays=1083/0.03/5.3/0, dsn=4.7.3, status=deferred (SASL authentication failed; server mail.server.fr[IpAddress]said: 535 5.7.3 Authentication unsuccessful)

And the metrics counter is empty:

postfix_smtpd_sasl_authentication_failures_total 0

have you an idea ?

Thanks you

0.4.0?

Looks like there are some nice commits after 0.3.0, specifically 3abd6f4, any possibility of cutting a new tag? Thanks

use systemd's sd_journal api to get log messages

That way, one does not have to set up syslogd writing to a new file, it is also more performant (not that that matters much).

The C functions one would use are:

  • sd_journal_open(3) or sd_journal_open_directory(3) (preferably make it configurable to specify the directory, for postfix running in containers),
  • sd_journal_add_match(3) to match for the right unit (will be "postfix.service" most of the time, but could be configurable),
  • sd_journal_seek_head(3) (or sd_journal_seek_cursor(3) if you want to jump to a previous position),
  • sd_journal_next(3) and sd_journal_get_data(3) to get the raw data, you are moste likely interested in the "MESSAGE" only.

restructure internals

I have noticed that for each measurement we introduce, we need to touch many places of the code. Some of them are easy to miss.

  • the field needs to be added one place and initialized another place
  • the regexp needs to be added and used in a different place
  • the collection and description need to be added. These I keep forgetting.

I have been trying to find a better structure, but no luck so far. I was thinking of having a separate struct with behaviour for each case, but the nested regexp makes it hard.

Maybe someone has a good idea on how to do it.

Make systemd optional

Is it possible to create a build tag to disable systemd for this exporter?
Not everyone has it installed, and if you build from source the systemd headers are required to build it.

postfix exporter prometheus queries

Hello,

I see there are a good number of metrics getting generated.
but I was wondering if someone has used those in PromQL to utilize for record and alert based on that.
Please share some ideas/files if you have created .

thanks

Improve statistics

I'm trying out this exporter instead of the SNMP exporter I wrote in perl years ago...

In gathering statistics, there's a number of lines missing that would be useful. These include:

  • postscreen rejections
  • spamassassin rejections

A lot of these seems to be ignored as unsupported lines.

If it helps, these are the regex queries I log via perl to extract my stats to SNMP... I'm a bit unsure how they'd translate though:

        if ( $prog eq 'postfix' ) {
                $line =~ /(\w+)\[\d+\]: (.*)$/;
                my $subprog = $1;
                $line = $2;
                if ( $subprog eq 'smtp' ) {
                        if ( $line =~ /\bstatus=sent\b/ ) {
                                $counts{"sent"}++;
                        }
                        elsif ( $line =~ /\bstatus=bounced\b/ ) {
                                $counts{"bounced"}++;
                        }
                        elsif ( $line =~ /NOQUEUE: reject:/ ) {
                                $counts{"rejected"}++;
                        }
                }
                elsif ( $subprog eq 'postscreen' ) {
                        if ( $line =~ /NOQUEUE: reject:/ ) {
                                $counts{"rejected"}++;
                        }
                }
                elsif ( $subprog eq 'smtpd' ) {
                        if ( $line =~ /NOQUEUE: reject:/ ) {
                                $counts{"rejected"}++;
                        }
                        elsif ( $line =~ /User unknown/ ) {
                                $counts{"bounced"}++;
                        }
                }
                elsif ( $subprog eq 'cleanup' ) {
                        if ( $line =~ /Blocked by SpamAssassin/ ) {
                                $counts{"spam"}++;
                        }
                        elsif ( $line =~ /[0-9A-F]+: (?:reject|discard): / ) {
                                $counts{"rejected"}++;
                        }
                }
                elsif ( $subprog eq 'pipe' ) {
                        if ( $line =~ /relay=dovecot/ ) {
                                $counts{"recv"}++;
                        }
                }
        }
        elsif ( $prog eq 'clamav-milter' ) {
                if ( $line =~ /infected by/ ) {
                        $counts{"virus"}++;
                }
        }

Metric Documentation

I can't seem to find any documentation on the metrics for this exporter.

Most of them are self-explanatory, I know, but it is very unclear to me what "le" is supposed to mean.

It would be very helpful to have a simple explanation and listing of the metrics that this exporter delivers.

incomplete instructions

Please spend some time on your documentation.

root@mail:# git clone https://github.com/kumina/postfix_exporter.git
robert@mail:
$ sudo apt-get install golang-go
robert@mail:~/postfix_exporter$ go build
main.go:9:2: cannot find package "github.com/alecthomas/kingpin" in any of:
/usr/lib/go-1.10/src/github.com/alecthomas/kingpin (from $GOROOT)
/home/robert/go/src/github.com/alecthomas/kingpin (from $GOPATH)
systemd.go:12:2: cannot find package "github.com/coreos/go-systemd/v22/sdjournal" in any of:
/usr/lib/go-1.10/src/github.com/coreos/go-systemd/v22/sdjournal (from $GOROOT)
/home/robert/go/src/github.com/coreos/go-systemd/v22/sdjournal (from $GOPATH)
postfix_exporter.go:30:2: cannot find package "github.com/hpcloud/tail" in any of:
/usr/lib/go-1.10/src/github.com/hpcloud/tail (from $GOROOT)
/home/robert/go/src/github.com/hpcloud/tail (from $GOPATH)
main.go:10:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
/usr/lib/go-1.10/src/github.com/prometheus/client_golang/prometheus (from $GOROOT)
/home/robert/go/src/github.com/prometheus/client_golang/prometheus (from $GOPATH)
main.go:11:2: cannot find package "github.com/prometheus/client_golang/prometheus/promhttp" in any of:
/usr/lib/go-1.10/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOROOT)
/home/robert/go/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOPATH)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.