From 4991a51208022a98be7d84f6cf49f5bf02486819 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 4 Nov 2025 19:11:23 +0100 Subject: [PATCH] MINOR: stats: Add stats about request and response bytes received and sent 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 | 2 +- include/haproxy/stats-t.h | 5 ++++- src/stats-file.c | 2 +- src/stats-proxy.c | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/haproxy/stats-file-t.h b/include/haproxy/stats-file-t.h index 03c65c3b4..a56cba65f 100644 --- a/include/haproxy/stats-file-t.h +++ b/include/haproxy/stats-file-t.h @@ -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 diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 937f77138..1ca0621da 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -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 }; diff --git a/src/stats-file.c b/src/stats-file.c index 5ccf0c4da..4152726ae 100644 --- a/src/stats-file.c +++ b/src/stats-file.c @@ -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"); diff --git a/src/stats-proxy.c b/src/stats-proxy.c index a7094653c..a94bed221 100644 --- a/src/stats-proxy.c +++ b/src/stats-proxy.c @@ -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 should be hidden. -- 2.47.3