]> granicus.if.org Git - pdns/commitdiff
dnsdist: Fix handling of latency-sum and latency-count in prometheus
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 2 Oct 2019 08:44:44 +0000 (10:44 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 2 Oct 2019 08:44:44 +0000 (10:44 +0200)
pdns/dnsdist-web.cc
pdns/dnsdist.hh

index c5d4cf343f40081347a4b7bf7e01eb10f02c126c..586547a2d47b7adf4ad2bd74583b00597d109ce5 100644 (file)
@@ -406,6 +406,7 @@ static void connectionThread(int sock, ComboAddress remote)
         resp.status = 200;
 
         std::ostringstream output;
+        static const std::set<std::string> metricBlacklist = { "latency-count", "latency-sum" };
         for (const auto& e : g_stats.entries) {
           if (e.first == "special-memory-usage")
             continue; // Too expensive for get-all
@@ -413,9 +414,11 @@ static void connectionThread(int sock, ComboAddress remote)
 
           // Prometheus suggest using '_' instead of '-'
           std::string prometheusMetricName = "dnsdist_" + boost::replace_all_copy(metricName, "-", "_");
+          if (metricBlacklist.count(metricName) != 0) {
+            continue;
+          }
 
           MetricDefinition metricDetails;
-
           if (!g_metricDefinitions.getMetricDetails(metricName, metricDetails)) {
               vinfolog("Do not have metric details for %s", metricName);
               continue;
@@ -458,6 +461,8 @@ static void connectionThread(int sock, ComboAddress remote)
         output << "dnsdist_latency_bucket{le=\"1000\"} " << latency_amounts << "\n";
         latency_amounts += g_stats.latencySlow; // Should be the same as latency_count
         output << "dnsdist_latency_bucket{le=\"+Inf\"} " << latency_amounts << "\n";
+        output << "dnsdist_latency_sum " << g_stats.latencySum << "\n";
+        output << "dnsdist_latency_count " << getLatencyCount(std::string()) << "\n";
 
         auto states = g_dstates.getLocal();
         const string statesbase = "dnsdist_server_";
index e686335adc266f9a21f73378ef9666e0e3e9114c..e654b9e1556a1b0db57342e435966cb823052470 100644 (file)
@@ -396,9 +396,6 @@ struct MetricDefinitionStorage {
     { "dyn-blocked",            MetricDefinition(PrometheusMetricType::counter, "Number of queries dropped because of a dynamic block")},
     { "dyn-block-nmg-size",     MetricDefinition(PrometheusMetricType::gauge,   "Number of dynamic blocks entries") },
     { "security-status",        MetricDefinition(PrometheusMetricType::gauge,   "Security status of this software. 0=unknown, 1=OK, 2=upgrade recommended, 3=upgrade mandatory") },
-    // Latency histogram
-    { "latency-sum",            MetricDefinition(PrometheusMetricType::counter, "Total response time in milliseconds")},
-    { "latency-count",          MetricDefinition(PrometheusMetricType::counter, "Number of queries contributing to response time histogram")},
   };
 };