]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
For Prometheus output, ad HELP and TYPE
authorOtto <otto.moerbeek@open-xchange.com>
Tue, 29 Jun 2021 08:29:54 +0000 (10:29 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 29 Jun 2021 13:07:42 +0000 (15:07 +0200)
pdns/rec_channel_rec.cc
pdns/recursordist/rec_metrics.hh
pdns/ws-recursor.cc

index 5ed2f9ece52766f86eebcff5f08dc9d480ef8604..0c6b223eaf1209acf4643727304d7d887c99eb29 100644 (file)
@@ -1375,13 +1375,13 @@ static void registerAllStats1()
     addGetStat(name, &(SyncRes::s_ecsResponsesBySubnetSize6.at(idx)));
   }
 
-  addGetStat("cumulativeAnswers-usec-", []() {
+  addGetStat("cumul-answers", []() {
     return toStatsMap(g_stats.cumulativeAnswers.getName(), g_stats.cumulativeAnswers);
   });
-  addGetStat("cumulativeAuth4Answers-usec-", []() {
+  addGetStat("cumul-auth4answers", []() {
     return toStatsMap(g_stats.cumulativeAuth4Answers.getName(), g_stats.cumulativeAuth4Answers);
   });
-  addGetStat("cumulativeAuth6Answers-usec-", []() {
+  addGetStat("cumul-auth6answers", []() {
     return toStatsMap(g_stats.cumulativeAuth6Answers.getName(), g_stats.cumulativeAuth6Answers);
   });
 }
index 39b15deeb6e49ebbf419c019e4c5580959942f93..59921825a25a53fb207b1216bdbf1e41bf79d7ca 100644 (file)
@@ -33,7 +33,8 @@
 enum class PrometheusMetricType : int
 {
   counter = 1,
-  gauge = 2
+  gauge = 2,
+  histogram = 3
 };
 
 // Keeps additional information about metrics
@@ -79,6 +80,9 @@ public:
     case PrometheusMetricType::gauge:
       return "gauge";
       break;
+    case PrometheusMetricType::histogram:
+      return "histogram";
+      break;
     default:
       return "";
       break;
index a65e60795da4e40e9325ea8374d724e599166d0c..71566be97146e52dc0590d6601f67951bf3ae009 100644 (file)
@@ -446,7 +446,6 @@ static void prometheusMetrics(HttpRequest *req, HttpResponse *resp) {
     for (const auto& tup : varmap) {
         std::string metricName = tup.first;
         std::string prometheusMetricName = tup.second.d_prometheusName;
-
         MetricDefinition metricDetails;
 
         if (s_metricDefinitions.getMetricDetails(metricName, metricDetails)) {
@@ -456,7 +455,13 @@ static void prometheusMetrics(HttpRequest *req, HttpResponse *resp) {
           if (prometheusTypeName.empty()) {
             continue;
           }
-
+          if (metricDetails.prometheusType == PrometheusMetricType::histogram) {
+            // name is XXX_count, strip the _count part
+            prometheusMetricName = prometheusMetricName.substr(0, prometheusMetricName.length() - 6);
+            output << "# HELP " << prometheusMetricName << " " << metricDetails.description << "\n";
+            output << "# TYPE " << prometheusMetricName << " " << prometheusTypeName << "\n";
+            continue;
+          }
           // for these we have the help and types encoded in the sources:
           output << "# HELP " << prometheusMetricName << " " << metricDetails.description << "\n";
           output << "# TYPE " << prometheusMetricName << " " << prometheusTypeName << "\n";
@@ -1029,9 +1034,21 @@ const std::map<std::string, MetricDefinition> MetricDefinitionStorage::metrics =
     MetricDefinition(PrometheusMetricType::counter,
                      "Number of outgoing DoT queries since starting")},
 
+  // For cumulative histogram, state the xxx_count name where xxx matches the name in rec_channel_rec
+  { "cumul-answers-count",
+    MetricDefinition(PrometheusMetricType::histogram,
+                     "histogram of our answer times")},
+  // For cumulative histogram, state the xxx_count name where xxx matches the name in rec_channel_rec
+  { "cumul-auth4answers-count",
+    MetricDefinition(PrometheusMetricType::histogram,
+                     "histogram of authoritative answer times over IPv4")},
+  // For cumulative histogram, state the xxx_count name where xxx matches the name in rec_channel_rec
+  { "cumul-auth6answers-count",
+    MetricDefinition(PrometheusMetricType::histogram,
+                     "histogram of authoritative answer times over IPV6")},
 };
 
-#define CHECK_PROMETHEUS_METRICS 0
+#define CHECK_PROMETHEUS_METRICS 1
 
 #if CHECK_PROMETHEUS_METRICS
 static void validatePrometheusMetrics()