Label target removed.

This label is redundant to instance, so prometheus provides already a
label for it.
This commit is contained in:
Denis Knauf 2021-05-09 17:24:01 +02:00
parent 392ac36312
commit 9817156b7a

View file

@ -37,7 +37,7 @@ class DnsblCollector
def registry= registry
@registry = registry
@registry.counter :dnsbl_query_error_count, docstring: 'Errors while query for blacklist', labels: %i[blacklist target]
@registry.counter :dnsbl_query_error_count, docstring: 'Errors while query for blacklist', labels: %i[blacklist]
@registry.counter :dnsbl_query_blacklist_duration_sum, docstring: 'Total duration for querieng this blacklist', labels: %i[blacklist]
@registry.counter :dnsbl_query_blacklist_count, docstring: 'Total count of queries this blacklist', labels: %i[blacklist]
end
@ -49,7 +49,7 @@ class DnsblCollector
def initialize registry: nil
@registry = registry || Prometheus::Client::Registry.new
@registry.gauge :dnsbl_listed, docstring: 'IP listed currently on Blacklist', labels: %i[blacklist target]
@registry.gauge :dnsbl_listed, docstring: 'IP listed currently on Blacklist', labels: %i[blacklist]
@metrics = OpenStruct.new @registry.instance_variable_get( :@metrics).merge( self.class.registry.instance_variable_get( :@metrics))
end
@ -64,9 +64,9 @@ class DnsblCollector
name, b = bl[:blacklist], Time.now
begin
r = resolver.search( "#{prefix}.#{name}", Net::DNS::A).answer.empty?
@metrics.dnsbl_listed.set r ? 0 : 1, labels: {blacklist: name, target: ip}
@metrics.dnsbl_listed.set r ? 0 : 1, labels: {blacklist: name}
rescue Net::DNS::Resolver::NoResponseError
@metrics.dnsbl_query_error_count.increment labels: {blacklist: name, target: ip}
@metrics.dnsbl_query_error_count.increment labels: {blacklist: name}
end
dur = Time.now-b
@metrics.dnsbl_query_blacklist_duration_sum.increment by: dur, labels: {blacklist: name}