diff --git a/config.ru b/config.ru index d8b5a96..2e21f2c 100644 --- a/config.ru +++ b/config.ru @@ -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 diff --git a/lib/collector/dovecot.rb b/lib/collector/dovecot.rb index 463c3dc..6124627 100644 --- a/lib/collector/dovecot.rb +++ b/lib/collector/dovecot.rb @@ -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