From c555fbeb626860f8f659b7c1864b942658bbf174 Mon Sep 17 00:00:00 2001
From: Alexander Stephan <alexander.stephan@sap.com>
Date: Mon, 6 Jul 2026 09:26:58 +0000
Subject: [PATCH 5/5] DOC: management: document 'clear counters server'

Add a section for the new 'clear counters server <backend>/<server>
[force]' CLI command in doc/management.txt, alongside 'clear counters'
and 'clear counters all'.

The entry documents the admin-only permission level (it clears
accumulated counters, like 'clear counters all') and the fact that both
accumulated counters and max values are reset, along with the clearable
module-registered extra counters, while the server's runtime state
(address, weight, admin state) and health checks are left untouched. It
describes the optional 'force' argument required to clear counters
stored in a shared-memory stats file, and calls out the Kubernetes
slot-recycle use case that motivated the command (per-entity
attribution after 'set server <b>/<s> name').
---
 doc/management.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/doc/management.txt b/doc/management.txt
index ab5b05ed4..e432e5f57 100644
--- a/doc/management.txt
+++ b/doc/management.txt
@@ -1913,6 +1913,30 @@ clear counters all
   server. This has the same effect as restarting. This command is restricted
   and can only be issued on sockets configured for level "admin".
 
+clear counters server <backend>/<server> [force]
+  Reset the statistics counters of a single server. This command is useful when
+  a server slot is being reused to represent a different logical entity (e.g.
+  a different Kubernetes pod occupying the same slot after a rename via
+  "set server <b>/<s> name") and per-entity counter attribution is required.
+  It behaves like "clear counters all" but scoped to one server rather than the
+  whole process.
+
+  The reset covers both accumulated counters (bytes, sessions, requests,
+  errors, response codes) and max values, as well as the extra counters
+  registered by modules (e.g. mux stats) for that server. As for the plain
+  "clear counters", only clearable modules are reset. It does not affect the
+  server's runtime state (address, weight, admin state) or health checks.
+
+  When the server's counters are stored in a shared-memory stats file (see
+  "shm-stats-file"), clearing them breaks the monotonicity that monitoring
+  tools consuming the shared stats rely on, and the reset is visible to every
+  process attached to the same object. For this reason the command refuses to
+  clear such a server unless the "force" keyword is appended.
+
+  Because it clears accumulated counters, this command is restricted and can
+  only be issued on sockets configured for level "admin", like "clear counters
+  all".
+
 clear acl [@<ver>] <acl>
   Remove all entries from the acl <acl>. <acl> is the #<id> or the <name>
   returned by "show acl". Note that if the reference <acl> is a name and is
-- 
2.43.7

