]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: Add stats about request and response bytes received and sent
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 4 Nov 2025 18:11:23 +0000 (19:11 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Nov 2025 14:01:29 +0000 (15:01 +0100)
In previous patches, these counters were added per frontend, backend, server
and listener. With this patch, these counters are reported on stats,
including promex.

Note that the stats file minor version was incremented by one because the
shm_stats_file_object struct size has changed.

This patch is related to issue #1617.

include/haproxy/stats-file-t.h
include/haproxy/stats-t.h
src/stats-file.c
src/stats-proxy.c

index 03c65c3b489666af09a49e015a7e2057a7f941a8..a56cba65fd239c583558cc4f2dfbbd1fba870446 100644 (file)
@@ -15,7 +15,7 @@ enum stfile_domain {
 };
 
 #define SHM_STATS_FILE_VER_MAJOR         1
-#define SHM_STATS_FILE_VER_MINOR         0
+#define SHM_STATS_FILE_VER_MINOR         1
 
 #define SHM_STATS_FILE_HEARTBEAT_TIMEOUT 60 /* passed this delay (seconds) process which has not
                                              * sent heartbeat will be considered down
index 937f77138b48772364b5f6bcf467a1e6c023eb17..1ca0621da3dedbccdd7e358110b5c6c47b444a2f 100644 (file)
@@ -489,7 +489,10 @@ enum stat_idx_px {
        ST_I_PX_H3REQ,
        ST_I_PX_PROTO,
        ST_I_PX_PRIV_IDLE_CUR,
-
+       ST_I_PX_REQ_IN,
+       ST_I_PX_REQ_OUT,
+       ST_I_PX_RES_IN,
+       ST_I_PX_RES_OUT,
        /* must always be the last one */
        ST_I_PX_MAX
 };
index 5ccf0c4dadd86937e89a6f4c530911014fa2b6be..4152726aefbda5a83b7192e5bdef5cac9370252c 100644 (file)
@@ -821,7 +821,7 @@ int shm_stats_file_prepare(void)
        BUG_ON(sizeof(struct shm_stats_file_hdr) != 672, "shm_stats_file_hdr struct size changed, "
               "it is part of the exported API: ensure all precautions were taken (ie: shm_stats_file "
               "version change) before adjusting this");
-       BUG_ON(sizeof(struct shm_stats_file_object) != 536, "shm_stats_file_object struct size changed, "
+       BUG_ON(sizeof(struct shm_stats_file_object) != 552, "shm_stats_file_object struct size changed, "
               "it is part of the exported API: ensure all precautions were taken (ie: shm_stats_file "
               "version change) before adjusting this");
 
index a7094653c666a5082e90433685fc7a3b8db938ac..a94bed221175c14fa43925d99a3f518f726e6833 100644 (file)
@@ -192,6 +192,11 @@ const struct stat_col stat_cols_px[ST_I_PX_MAX] = {
        [ST_I_PX_H3REQ]         = ME_NEW_FE_SHARED("h3req",         NULL,                            FN_COUNTER, FF_U64, p.http.cum_req[3],      STATS_PX_CAP__F__, "Total number of HTTP/3 sessions processed by this object since the worker process started"),
        [ST_I_PX_PROTO]                         = { .name = "proto",                       .alt_name = NULL,                              .desc = "Protocol" },
        [ST_I_PX_PRIV_IDLE_CUR]                 = { .name = "priv_idle_cur",               .alt_name = "private_idle_connections_current",.desc = "Current number of private idle connections", .cap = STATS_PX_CAP____S},
+       [ST_I_PX_REQ_IN]        = ME_NEW_PX_SHARED("reqin",        "req_in_total",                  FN_COUNTER, FF_U64, req_in,               STATS_PX_CAP_LFBS, "Total number of request bytes received since process started"),
+       [ST_I_PX_REQ_OUT]       = ME_NEW_PX_SHARED("reqout",       "req_out_total",                 FN_COUNTER, FF_U64, req_out,              STATS_PX_CAP_LFBS, "Total number of request bytes sent since process started"),
+       [ST_I_PX_RES_IN]        = ME_NEW_PX_SHARED("resin",        "res_in_total",                  FN_COUNTER, FF_U64, res_in,               STATS_PX_CAP_LFBS, "Total number of response bytes received since process started"),
+       [ST_I_PX_RES_OUT]       = ME_NEW_PX_SHARED("resout",       "res_out_total",                 FN_COUNTER, FF_U64, res_out,              STATS_PX_CAP_LFBS, "Total number of response bytes sent since process started"),
+
 };
 
 /* Returns true if column at <idx> should be hidden.