fixes: dovecot saved mails counter. labels options for queued

This commit is contained in:
Denis Knauf 2022-10-03 13:54:07 +02:00
parent 29a9205508
commit 24858883b4
2 changed files with 4 additions and 4 deletions

View file

@ -19,7 +19,7 @@ collector.start
showqpath = '/var/spool/postfix/public/showq' showqpath = '/var/spool/postfix/public/showq'
prometheus = collector.prometheus prometheus = collector.prometheus
metrics = OpenStruct.new( metrics = OpenStruct.new(
queued: prometheus.gauge( :postfix_queued, docstring: "Queued mails per queue and sender/recipient"), queued: prometheus.gauge( :postfix_queued, docstring: "Queued mails per queue and sender/recipient", labels: %i[queue sender recipient]),
) )
def determine_domain str def determine_domain str
@ -54,7 +54,7 @@ run lambda {|env|
showq.group_by do |e| showq.group_by do |e|
{queue: e['queue_name'], sender: determine_domain( e['sender']), recipient: determine_domain( e['recipient'])} {queue: e['queue_name'], sender: determine_domain( e['sender']), recipient: determine_domain( e['recipient'])}
end.each do |labels, entries| end.each do |labels, entries|
metrics.queued.set labels, entries.length if labels and labels[:queue] metrics.queued.set entries.length, labels: labels if labels and labels[:queue]
end end
[200, {"Content-Type" => "text/plain"}, [Prometheus::Client::Formats::Text.marshal( prometheus)]] [200, {"Content-Type" => "text/plain"}, [Prometheus::Client::Formats::Text.marshal( prometheus)]]
else else

View file

@ -130,13 +130,13 @@ class Collector::Dovecot
def initialize store, prometheus def initialize store, prometheus
@store = store @store = store
@saved_mail_to_mailbox = prometheus.counter :saved_mail_to_mailbox_total, docstring: "A counter of saved mails to mailbox directly", labels: %i[process]
@auth_errors = prometheus.counter :auth_errors_total, docstring: "A counter of dovecot auth errors by type.", labels: %i[error]
@sieve = Sieve.new store, Collector::PrefixProxy.new( prometheus, :sieve) @sieve = Sieve.new store, Collector::PrefixProxy.new( prometheus, :sieve)
@lmtp = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :lmtp @lmtp = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :lmtp
@deliver = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :deliver @deliver = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :deliver
@imap_login = ImapLogin.new store, prometheus @imap_login = ImapLogin.new store, prometheus
@imap = Imap.new store, prometheus @imap = Imap.new store, prometheus
@saved_mail_to_mailbox = prometheus.counter :saved_mail_to_mailbox_total, docstring: "A counter of saved mails to mailbox directly", labels: %i[process]
@auth_errors = prometheus.counter :auth_errors_total, docstring: "A counter of dovecot auth errors by type.", labels: %i[error]
end end
def collect entry def collect entry