From: Otto Date: Tue, 14 Sep 2021 07:43:42 +0000 (+0200) Subject: _count and _sum should be per label as noted by @wojas X-Git-Tag: dnsdist-1.7.0-alpha1~22^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b23c9af09ac9f6b438c7f2660f87522d44457fa1;p=thirdparty%2Fpdns.git _count and _sum should be per label as noted by @wojas --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 7213d97f2e..bf2b115640 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -1155,6 +1155,9 @@ static StatsMap toStatsMap(const string& name, const pdns::AtomicHistogram& hist (bucket.d_boundary == std::numeric_limits::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::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; } diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index a156637ceb..58d310e469 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -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 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",