]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
_count and _sum should be per label as noted by @wojas
authorOtto <otto.moerbeek@open-xchange.com>
Tue, 14 Sep 2021 07:43:42 +0000 (09:43 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 14 Sep 2021 07:43:42 +0000 (09:43 +0200)
pdns/rec_channel_rec.cc
pdns/ws-recursor.cc

index 7213d97f2e366148f91ccae03a0e7d68a91a7eed..bf2b11564062872bfab037944cf9e35350a6892a 100644 (file)
@@ -1155,6 +1155,9 @@ static StatsMap toStatsMap(const string& name, const pdns::AtomicHistogram& hist
       (bucket.d_boundary == std::numeric_limits<uint64_t>::max() ? "+Inf" : buf) + "\"}";
     entries.emplace(bucket.d_name + "4", StatsMapEntry{pname, std::to_string(bucket.d_count)});
   }
+  snprintf(buf, sizeof(buf), "%g", histogram4.getSum() / 1e6);
+  entries.emplace(name + "sum4", StatsMapEntry{pbasename + "seconds_count{ipversion=\"v4\"}", buf});
+  entries.emplace(name + "count4", StatsMapEntry{pbasename + "seconds_count{ipversion=\"v4\"}", std::to_string(data4.back().d_count)});
 
   const auto& data6 = histogram6.getCumulativeBuckets();
   for (const auto& bucket : data6) {
@@ -1163,10 +1166,9 @@ static StatsMap toStatsMap(const string& name, const pdns::AtomicHistogram& hist
       (bucket.d_boundary == std::numeric_limits<uint64_t>::max() ? "+Inf" : buf) + "\"}";
     entries.emplace(bucket.d_name + "6", StatsMapEntry{pname, std::to_string(bucket.d_count)});
   }
-
-  snprintf(buf, sizeof(buf), "%g", (histogram4.getSum() +  histogram6.getSum()) / 1e6);
-  entries.emplace(name + "sum", StatsMapEntry{pbasename + "seconds_sum", buf});
-  entries.emplace(name + "count", StatsMapEntry{pbasename + "seconds_count", std::to_string(data4.back().d_count + data6.back().d_count)});
+  snprintf(buf, sizeof(buf), "%g", histogram6.getSum() / 1e6);
+  entries.emplace(name + "sum6", StatsMapEntry{pbasename + "seconds_count{ipversion=\"v6\"}", buf});
+  entries.emplace(name + "count6", StatsMapEntry{pbasename + "seconds_count{ipversion=\"v6\"}", std::to_string(data6.back().d_count)});
 
   return entries;
 }
index a156637ceb880fc5696ba6ed5cab3f12cfdd1bd3..58d310e4692738a7ebe25bfdd11a8d9792549981 100644 (file)
@@ -460,8 +460,9 @@ static void prometheusMetrics(HttpRequest *req, HttpResponse *resp) {
             helpname = prometheusMetricName.substr(0, prometheusMetricName.find('{'));
           }
           else if (metricDetails.d_prometheusType == PrometheusMetricType::histogram) {
+            helpname = prometheusMetricName.substr(0, prometheusMetricName.find('{'));
             // name is XXX_count, strip the _count part
-            helpname = prometheusMetricName.substr(0, prometheusMetricName.length() - 6);
+            helpname = helpname.substr(0, helpname.length() - 6);
           }
           output << "# TYPE " << helpname << " " << prometheusTypeName << "\n";
           output << "# HELP " << helpname << " " << metricDetails.d_description << "\n";
@@ -1065,7 +1066,7 @@ const std::map<std::string, MetricDefinition> MetricDefinitionStorage::d_metrics
     MetricDefinition(PrometheusMetricType::histogram,
                      "histogram of our answer times to clients")},
   // For cumulative histogram, state the xxx_count name where xxx matches the name in rec_channel_rec
-  { "cumul-authanswers-count",
+  { "cumul-authanswers-count4",
     MetricDefinition(PrometheusMetricType::histogram,
                      "histogram of answer times of authoritative servers")},
   { "almost-expired-pushed",