diff --git a/dnsbl_exporter.rb b/dnsbl_exporter.rb index 31a7cf8..c0d60ad 100644 --- a/dnsbl_exporter.rb +++ b/dnsbl_exporter.rb @@ -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}