From 5057253a10017144d34a2da9545a7205ad807c2e Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 9 Nov 2023 09:06:30 +0100 Subject: [PATCH] dnsdist: Add missing DoQ latency metrics --- .github/actions/spell-check/expect.txt | 1 + pdns/dnsdist-web.cc | 4 ++++ pdns/dnsdist.cc | 6 ++++++ pdns/dnsdistdist/dnsdist-metrics.cc | 4 ++++ pdns/dnsdistdist/dnsdist-metrics.hh | 1 + pdns/dnsdistdist/docs/statistics.rst | 20 ++++++++++++++++++++ pdns/dnsdistdist/html/index.html | 2 +- pdns/dnsdistdist/html/local.js | 1 + regression-tests.dnsdist/test_API.py | 3 ++- 9 files changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 99ca1cfd39..d11470aafe 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -346,6 +346,7 @@ domainname domainrelatedobject Donatas dontcare +doq downsides downstreams dport diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 69f543621e..c4cf702f50 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -176,6 +176,10 @@ std::map MetricDefinitionStorage::metrics{ { "latency-doh-avg1000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 1000 packets received over DoH")}, { "latency-doh-avg10000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 10000 packets received over DoH")}, { "latency-doh-avg1000000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 1000000 packets received over DoH")}, + { "latency-doq-avg100", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 100 packets received over DoQ")}, + { "latency-doq-avg1000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 1000 packets received over DoQ")}, + { "latency-doq-avg10000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 10000 packets received over DoQ")}, + { "latency-doq-avg1000000", MetricDefinition(PrometheusMetricType::gauge, "Average response latency, in microseconds, of the last 1000000 packets received over DoQ")}, { "uptime", MetricDefinition(PrometheusMetricType::gauge, "Uptime of the dnsdist process in seconds")}, { "real-memory-usage", MetricDefinition(PrometheusMetricType::gauge, "Current memory usage in bytes")}, { "noncompliant-queries", MetricDefinition(PrometheusMetricType::counter, "Number of queries dropped as non-compliant")}, diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index dc490d2e22..34d0f71f60 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -317,6 +317,12 @@ static void doLatencyStats(dnsdist::Protocol protocol, double udiff) doAvg(dnsdist::metrics::g_stats.latencyDoHAvg10000, udiff, 10000); doAvg(dnsdist::metrics::g_stats.latencyDoHAvg1000000, udiff, 1000000); } + else if (protocol == dnsdist::Protocol::DoQ) { + doAvg(dnsdist::metrics::g_stats.latencyDoQAvg100, udiff, 100); + doAvg(dnsdist::metrics::g_stats.latencyDoQAvg1000, udiff, 1000); + doAvg(dnsdist::metrics::g_stats.latencyDoQAvg10000, udiff, 10000); + doAvg(dnsdist::metrics::g_stats.latencyDoQAvg1000000, udiff, 1000000); + } } bool responseContentMatches(const PacketBuffer& response, const DNSName& qname, const uint16_t qtype, const uint16_t qclass, const std::shared_ptr& remote, unsigned int& qnameWireLength) diff --git a/pdns/dnsdistdist/dnsdist-metrics.cc b/pdns/dnsdistdist/dnsdist-metrics.cc index 6497a455d3..adf961eb8b 100644 --- a/pdns/dnsdistdist/dnsdist-metrics.cc +++ b/pdns/dnsdistdist/dnsdist-metrics.cc @@ -110,6 +110,10 @@ Stats::Stats() : {"latency-doh-avg1000", &latencyDoHAvg1000}, {"latency-doh-avg10000", &latencyDoHAvg10000}, {"latency-doh-avg1000000", &latencyDoHAvg1000000}, + {"latency-doq-avg100", &latencyDoQAvg100}, + {"latency-doq-avg1000", &latencyDoQAvg1000}, + {"latency-doq-avg10000", &latencyDoQAvg10000}, + {"latency-doq-avg1000000", &latencyDoQAvg1000000}, {"uptime", uptimeOfProcess}, {"real-memory-usage", getRealMemoryUsage}, {"special-memory-usage", getSpecialMemoryUsage}, diff --git a/pdns/dnsdistdist/dnsdist-metrics.hh b/pdns/dnsdistdist/dnsdist-metrics.hh index 37e75d1865..264054f672 100644 --- a/pdns/dnsdistdist/dnsdist-metrics.hh +++ b/pdns/dnsdistdist/dnsdist-metrics.hh @@ -84,6 +84,7 @@ struct Stats double latencyTCPAvg100{0}, latencyTCPAvg1000{0}, latencyTCPAvg10000{0}, latencyTCPAvg1000000{0}; double latencyDoTAvg100{0}, latencyDoTAvg1000{0}, latencyDoTAvg10000{0}, latencyDoTAvg1000000{0}; double latencyDoHAvg100{0}, latencyDoHAvg1000{0}, latencyDoHAvg10000{0}, latencyDoHAvg1000000{0}; + double latencyDoQAvg100{0}, latencyDoQAvg1000{0}, latencyDoQAvg10000{0}, latencyDoQAvg1000000{0}; using statfunction_t = std::function; using entry_t = std::variant*, double*, statfunction_t>; struct EntryPair diff --git a/pdns/dnsdistdist/docs/statistics.rst b/pdns/dnsdistdist/docs/statistics.rst index 0d5b5ed1c5..664c38df56 100644 --- a/pdns/dnsdistdist/docs/statistics.rst +++ b/pdns/dnsdistdist/docs/statistics.rst @@ -68,6 +68,10 @@ doh-response-pipe-full ---------------------- Number of responses dropped because the internal DoH pipe was full. +doq-response-pipe-full +---------------------- +Number of responses dropped because the internal DoQ pipe was full. + downstream-send-errors ---------------------- Number of errors when sending a query to a backend. @@ -145,6 +149,22 @@ latency-doh-avg1000000 ---------------------- Average response latency, in microseconds, of the last 1000000 packets received over DoH. +latency-doq-avg100 +------------------ +Average response latency, in microseconds, of the last 100 packets received over DoQ. + +latency-doq-avg1000 +------------------- +Average response latency, in microseconds, of the last 1000 packets received over DoQ. + +latency-doq-avg10000 +-------------------- +Average response latency, in microseconds, of the last 10000 packets received over DoQ. + +latency-doq-avg1000000 +---------------------- +Average response latency, in microseconds, of the last 1000000 packets received over DoQ. + latency-dot-avg100 ------------------ Average response latency, in microseconds, of the last 100 packets received over DoT. diff --git a/pdns/dnsdistdist/html/index.html b/pdns/dnsdistdist/html/index.html index 4f3bc695e9..29571e9067 100644 --- a/pdns/dnsdistdist/html/index.html +++ b/pdns/dnsdistdist/html/index.html @@ -50,7 +50,7 @@

Uptime: , Number of queries: ( qps), ACL drops: , Dynamic drops: , Rule drops:
- Average response time: UDP ms, TCP ms, DoT ms, DoH ms
+ Average response time: UDP ms, TCP ms, DoT ms, DoH ms, DoQ ms
CPU Usage: %, Cache hitrate: %, Server selection policy:
Listening on: , ACL:

diff --git a/pdns/dnsdistdist/html/local.js b/pdns/dnsdistdist/html/local.js index 1db6999dba..4f9f125509 100644 --- a/pdns/dnsdistdist/html/local.js +++ b/pdns/dnsdistdist/html/local.js @@ -154,6 +154,7 @@ $(document).ready(function() { $("#latency-tcp").text((data["latency-tcp-avg10000"]/1000.0).toFixed(2)); $("#latency-dot").text((data["latency-dot-avg10000"]/1000.0).toFixed(2)); $("#latency-doh").text((data["latency-doh-avg10000"]/1000.0).toFixed(2)); + $("#latency-doq").text((data["latency-doq-avg10000"]/1000.0).toFixed(2)); if(!gdata["cpu-sys-msec"]) gdata=data; diff --git a/regression-tests.dnsdist/test_API.py b/regression-tests.dnsdist/test_API.py index d36da2e76e..322b63bbd5 100644 --- a/regression-tests.dnsdist/test_API.py +++ b/regression-tests.dnsdist/test_API.py @@ -32,7 +32,8 @@ class APITestsBase(DNSDistTest): 'latency-avg10000', 'latency-avg1000000', 'latency-tcp-avg100', 'latency-tcp-avg1000', 'latency-tcp-avg10000', 'latency-tcp-avg1000000', 'latency-dot-avg100', 'latency-dot-avg1000', 'latency-dot-avg10000', 'latency-dot-avg1000000', 'latency-doh-avg100', 'latency-doh-avg1000', - 'latency-doh-avg10000', 'latency-doh-avg1000000', 'uptime', 'real-memory-usage', 'noncompliant-queries', + 'latency-doh-avg10000', 'latency-doh-avg1000000', 'latency-doq-avg100', 'latency-doq-avg1000', + 'latency-doq-avg10000', 'latency-doq-avg1000000','uptime', 'real-memory-usage', 'noncompliant-queries', 'noncompliant-responses', 'rdqueries', 'empty-queries', 'cache-hits', 'cache-misses', 'cpu-iowait', 'cpu-steal', 'cpu-sys-msec', 'cpu-user-msec', 'fd-usage', 'dyn-blocked', 'dyn-block-nmg-size', 'rule-servfail', 'rule-truncated', 'security-status', -- 2.47.2