From 9cfeea8536fcac7fdf8343abc32b3f4988b7ca45 Mon Sep 17 00:00:00 2001 From: Per Abich Date: Fri, 28 Feb 2020 15:05:52 +0100 Subject: [PATCH 1/2] Made the buckets sizes for Histograms measuring seconds into more "human" timspans (minutes, hours, days) --- postfix_exporter.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/postfix_exporter.go b/postfix_exporter.go index 2e2ec22..00bc9f4 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -458,6 +458,7 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal, return nil, err } } + timeBuckets := []float64{1e-3, 1e-2, 1e-1, 1.0, 10, 1 * 60, 1 * 60 * 60, 24 * 60 * 60, 2 * 24 * 60 * 60} return &PostfixExporter{ logUnsupportedLines: logUnsupportedLines, showqPath: showqPath, @@ -484,7 +485,7 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal, Namespace: "postfix", Name: "lmtp_delivery_delay_seconds", Help: "LMTP message processing time in seconds.", - Buckets: []float64{1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3}, + Buckets: timeBuckets, }, []string{"stage"}), pipeDelays: prometheus.NewHistogramVec( @@ -492,7 +493,7 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal, Namespace: "postfix", Name: "pipe_delivery_delay_seconds", Help: "Pipe message processing time in seconds.", - Buckets: []float64{1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3}, + Buckets: timeBuckets, }, []string{"relay", "stage"}), qmgrInsertsNrcpt: prometheus.NewHistogram(prometheus.HistogramOpts{ @@ -517,7 +518,7 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal, Namespace: "postfix", Name: "smtp_delivery_delay_seconds", Help: "SMTP message processing time in seconds.", - Buckets: []float64{1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3}, + Buckets: timeBuckets, }, []string{"stage"}), smtpTLSConnects: prometheus.NewCounterVec( From 4dda50457da7df47b33a6da36ede8b73604244ee Mon Sep 17 00:00:00 2001 From: cw-ozaki Date: Mon, 20 Jul 2020 22:12:44 +0900 Subject: [PATCH 2/2] fixes an issue where can't get metrics in systemd journal --- postfix_exporter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postfix_exporter.go b/postfix_exporter.go index b0e1089..787cb06 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -612,7 +612,7 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal, func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) { ch <- postfixUpDesc - if e.tailer == nil { + if e.tailer == nil && e.journal == nil { return } ch <- e.cleanupProcesses.Desc() @@ -700,7 +700,7 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) { e.showqPath) } - if e.tailer == nil { + if e.tailer == nil && e.journal == nil { return } ch <- e.cleanupProcesses