]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add prometheus type and help for 'cache_cleanup_count'
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Feb 2023 14:10:08 +0000 (15:10 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 14 Feb 2023 11:41:14 +0000 (12:41 +0100)
Also make sure that we test the caching metrics in our regression tests.

pdns/dnsdist-web.cc
regression-tests.dnsdist/test_Prometheus.py

index 267c05561de223c34590c56c968d4c1359b92a4a..24546351a251c9b8da85a7d5d8bfbafa5c533b12 100644 (file)
@@ -813,6 +813,8 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
   output << "# TYPE dnsdist_pool_cache_insert_collisions " << "counter" << "\n";
   output << "# HELP dnsdist_pool_cache_ttl_too_shorts " << "Number of insertions into that cache skipped because the TTL of the answer was not long enough" << "\n";
   output << "# TYPE dnsdist_pool_cache_ttl_too_shorts " << "counter" << "\n";
+  output << "# HELP dnsdist_pool_cache_cleanup_count_total " << "Number of times the cache has been scanned to remove expired entries, if any" << "\n";
+  output << "# TYPE dnsdist_pool_cache_cleanup_count_total " << "counter" << "\n";
 
   for (const auto& entry : *localPools) {
     string poolName = entry.first;
@@ -837,7 +839,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
       output << cachebase << "cache_lookup_collisions" <<label << " " << cache->getLookupCollisions() << "\n";
       output << cachebase << "cache_insert_collisions" <<label << " " << cache->getInsertCollisions() << "\n";
       output << cachebase << "cache_ttl_too_shorts"    <<label << " " << cache->getTTLTooShorts()     << "\n";
-      output << cachebase << "cache_cleanup_count"     <<label << " " << cache->getCleanupCount()     << "\n";
+      output << cachebase << "cache_cleanup_count_total"     <<label << " " << cache->getCleanupCount()     << "\n";
     }
   }
 
index 51d6f06a0886aae030132d03a067f5ede0be356b..61e4ee5ccc9530169a276b0fc6614a066f8b9022 100644 (file)
@@ -19,6 +19,8 @@ class TestPrometheus(DNSDistTest):
     newServer{address="127.0.0.1:%s"}
     webserver("127.0.0.1:%s")
     setWebserverConfig({password="%s", apiKey="%s"})
+    pc = newPacketCache(100, {maxTTL=86400, minTTL=1})
+    getPool(""):setCache(pc)
     """
 
     def checkPrometheusContentBasic(self, content):