From 9817156b7a634ea8b7f71b1f78a69e86fe01c2f6 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Sun, 9 May 2021 17:24:01 +0200 Subject: [PATCH] Label target removed. This label is redundant to instance, so prometheus provides already a label for it. --- dnsbl_exporter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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}