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'
prometheus = collector.prometheus
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
@ -54,7 +54,7 @@ run lambda {|env|
showq.group_by do |e|
{queue: e['queue_name'], sender: determine_domain( e['sender']), recipient: determine_domain( e['recipient'])}
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
[200, {"Content-Type" => "text/plain"}, [Prometheus::Client::Formats::Text.marshal( prometheus)]]
else

View file

@ -130,13 +130,13 @@ class Collector::Dovecot
def initialize store, prometheus
@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)
@lmtp = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :lmtp
@deliver = Delivery.new store, prometheus, @sieve, @saved_mail_to_mailbox, :deliver
@imap_login = ImapLogin.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
def collect entry