summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorFrantisek Tobias <frantisek.tobias@nic.cz>2024-08-19 17:16:38 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2024-08-19 17:16:38 +0200
commitb905135b48b64e034c1ea83cc9e759654b3aa2b3 (patch)
tree9a795530576928cb32024695b804fa9456431bf8 /modules
parentMerge !1588: validator: avoid clearing EDE if request didn't actually fail (diff)
downloadknot-resolver-b905135b48b64e034c1ea83cc9e759654b3aa2b3.tar.xz
knot-resolver-b905135b48b64e034c1ea83cc9e759654b3aa2b3.zip
modules/stats: add answer.stale
Diffstat (limited to 'modules')
-rw-r--r--modules/serve_stale/serve_stale.lua7
-rw-r--r--modules/stats/README.rst2
-rw-r--r--modules/stats/stats.c8
3 files changed, 14 insertions, 3 deletions
diff --git a/modules/serve_stale/serve_stale.lua b/modules/serve_stale/serve_stale.lua
index faf07fbe..c1528e80 100644
--- a/modules/serve_stale/serve_stale.lua
+++ b/modules/serve_stale/serve_stale.lua
@@ -8,9 +8,10 @@ local ffi = require('ffi')
M.timeout = 3*sec
M.callback = ffi.cast("kr_stale_cb",
- function (ttl) --, name, type, qry)
+ function (ttl, _, _, qry)
--log_debug(ffi.C.SRVSTALE, ' => called back with TTL: ' .. tostring(ttl))
if ttl + 3600 * 24 > 0 then -- at most one day stale
+ qry.request.stale_accounted = true
return 1
else
return -1
@@ -27,7 +28,9 @@ M.layer = {
local now = ffi.C.kr_now()
local deadline = qry.creation_time_mono + M.timeout
if now > deadline or qry.flags.NO_NS_FOUND then
- log_debug(ffi.C.LOG_GRP_SRVSTALE, ' => no reachable NS, using stale data')
+ log_qry(qry, ffi.C.LOG_GRP_SRVSTALE,
+ ' => no reachable NS, using stale data "%s"',
+ kres.dname2str(qry:name()))
qry.stale_cb = M.callback
-- TODO: probably start the same request that doesn't stale-serve,
-- but first we need some detection of non-interactive / internal requests.
diff --git a/modules/stats/README.rst b/modules/stats/README.rst
index 1def925c..e9258274 100644
--- a/modules/stats/README.rst
+++ b/modules/stats/README.rst
@@ -55,6 +55,8 @@ Built-in counters keep track of number of queries and answers matching specific
+-----------------+----------------------------------+
| answer.cached | queries answered from cache |
+-----------------+----------------------------------+
+| answer.stale | queries that utilized stale data |
++-----------------+----------------------------------+
+-----------------+----------------------------------+
| **Answers categorized by RCODE** |
diff --git a/modules/stats/stats.c b/modules/stats/stats.c
index deed9c94..596847d7 100644
--- a/modules/stats/stats.c
+++ b/modules/stats/stats.c
@@ -37,12 +37,17 @@
#define UPSTREAMS_COUNT 512 /* Size of recent upstreams */
#endif
-/** @cond internal Fixed-size map of predefined metrics. */
+/** @cond internal Fixed-size map of predefined metrics.
+ *
+ * When changing the list, don't forget _parse_resolver_metrics()
+ * in ../../manager/knot_resolver_manager/statistics.py
+ */
#define CONST_METRICS(X) \
X(answer,total) X(answer,noerror) X(answer,nodata) X(answer,nxdomain) X(answer,servfail) \
X(answer,cached) X(answer,1ms) X(answer,10ms) X(answer,50ms) X(answer,100ms) \
X(answer,250ms) X(answer,500ms) X(answer,1000ms) X(answer,1500ms) X(answer,slow) \
X(answer,sum_ms) \
+ X(answer,stale) \
X(answer,aa) X(answer,tc) X(answer,rd) X(answer,ra) X(answer, ad) X(answer,cd) \
X(answer,edns0) X(answer,do) \
X(query,edns) X(query,dnssec) \
@@ -303,6 +308,7 @@ static int collect(kr_layer_t *ctx)
DEPRECATED
use new names metric_answer_edns0 and metric_answer_do
*/
+ stat_const_add(data, metric_answer_stale, param->stale_accounted);
stat_const_add(data, metric_query_edns, knot_pkt_has_edns(param->answer));
stat_const_add(data, metric_query_dnssec, knot_pkt_has_dnssec(param->answer));