MINOR: stats: Expose native cum_req metric for a server
Expose native cum_req metric for a server: so far it was calculated as a
sum or all responses. Rename it from Cum. HTTP Responses to Cum. HTTP
Requests to be consistent with Frontend and Backend.
diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c
index 54770ef..f7542d2 100644
--- a/contrib/prometheus-exporter/service-prometheus.c
+++ b/contrib/prometheus-exporter/service-prometheus.c
@@ -2061,6 +2061,11 @@
case ST_F_LBTOT:
metric = mkf_u64(FN_COUNTER, sv->counters.cum_lbconn);
break;
+ case ST_F_REQ_TOT:
+ if (px->mode != PR_MODE_HTTP)
+ goto next_px;
+ metric = mkf_u64(FN_COUNTER, sv->counters.p.http.cum_req);
+ break;
case ST_F_HRSP_1XX:
if (px->mode != PR_MODE_HTTP)
goto next_px;
diff --git a/src/http_ana.c b/src/http_ana.c
index f6e0eca..5492b54 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -1721,8 +1721,10 @@
if (n == 4)
stream_inc_http_err_ctr(s);
- if (objt_server(s->target))
+ if (objt_server(s->target)) {
_HA_ATOMIC_ADD(&__objt_server(s->target)->counters.p.http.rsp[n], 1);
+ _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.p.http.cum_req, 1);
+ }
/* Adjust server's health based on status code. Note: status codes 501
* and 505 are triggered on demand by client request, so we must not
diff --git a/src/stats.c b/src/stats.c
index f76fd37..7548197 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1016,19 +1016,10 @@
/* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */
if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) {
- unsigned long long tot;
-
- tot = stats[ST_F_HRSP_OTHER].u.u64;
- tot += stats[ST_F_HRSP_1XX].u.u64;
- tot += stats[ST_F_HRSP_2XX].u.u64;
- tot += stats[ST_F_HRSP_3XX].u.u64;
- tot += stats[ST_F_HRSP_4XX].u.u64;
- tot += stats[ST_F_HRSP_5XX].u.u64;
-
chunk_appendf(out,
"<tr><th>New connections:</th><td>%s</td></tr>"
"<tr><th>Reused connections:</th><td>%s</td><td>(%d%%)</td></tr>"
- "<tr><th>Cum. HTTP responses:</th><td>%s</td></tr>"
+ "<tr><th>Cum. HTTP requests:</th><td>%s</td></tr>"
"<tr><th>- HTTP 1xx responses:</th><td>%s</td><td>(%d%%)</td></tr>"
"<tr><th>- HTTP 2xx responses:</th><td>%s</td><td>(%d%%)</td></tr>"
"<tr><th>- HTTP 3xx responses:</th><td>%s</td><td>(%d%%)</td></tr>"
@@ -1042,13 +1033,19 @@
U2H(stats[ST_F_REUSE].u.u64),
(stats[ST_F_CONNECT].u.u64 + stats[ST_F_REUSE].u.u64) ?
(int)(100 * stats[ST_F_REUSE].u.u64 / (stats[ST_F_CONNECT].u.u64 + stats[ST_F_REUSE].u.u64)) : 0,
- U2H(tot),
- U2H(stats[ST_F_HRSP_1XX].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_1XX].u.u64 / tot) : 0,
- U2H(stats[ST_F_HRSP_2XX].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_2XX].u.u64 / tot) : 0,
- U2H(stats[ST_F_HRSP_3XX].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_3XX].u.u64 / tot) : 0,
- U2H(stats[ST_F_HRSP_4XX].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_4XX].u.u64 / tot) : 0,
- U2H(stats[ST_F_HRSP_5XX].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_5XX].u.u64 / tot) : 0,
- U2H(stats[ST_F_HRSP_OTHER].u.u64), tot ? (int)(100 * stats[ST_F_HRSP_OTHER].u.u64 / tot) : 0,
+ U2H(stats[ST_F_REQ_TOT].u.u64),
+ U2H(stats[ST_F_HRSP_1XX].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_1XX].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
+ U2H(stats[ST_F_HRSP_2XX].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_2XX].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
+ U2H(stats[ST_F_HRSP_3XX].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_3XX].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
+ U2H(stats[ST_F_HRSP_4XX].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_4XX].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
+ U2H(stats[ST_F_HRSP_5XX].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_5XX].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
+ U2H(stats[ST_F_HRSP_OTHER].u.u64), stats[ST_F_REQ_TOT].u.u64 ?
+ (int)(100 * stats[ST_F_HRSP_OTHER].u.u64 / stats[ST_F_REQ_TOT].u.u64) : 0,
U2H(stats[ST_F_WREW].u.u64),
U2H(stats[ST_F_EINT].u.u64));
}
@@ -1796,6 +1793,7 @@
/* http response: 1xx, 2xx, 3xx, 4xx, 5xx, other */
if (px->mode == PR_MODE_HTTP) {
+ stats[ST_F_REQ_TOT] = mkf_u64(FN_COUNTER, sv->counters.p.http.cum_req);
stats[ST_F_HRSP_1XX] = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[1]);
stats[ST_F_HRSP_2XX] = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[2]);
stats[ST_F_HRSP_3XX] = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[3]);