diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index 54770ef5b..f7542d26b 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -2061,6 +2061,11 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) 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 f6e0eca3b..5492b54fe 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1721,8 +1721,10 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) 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 f76fd3790..754819734 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1016,19 +1016,10 @@ static int stats_dump_fields_html(struct buffer *out, /* 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, "New connections:%s" "Reused connections:%s(%d%%)" - "Cum. HTTP responses:%s" + "Cum. HTTP requests:%s" "- HTTP 1xx responses:%s(%d%%)" "- HTTP 2xx responses:%s(%d%%)" "- HTTP 3xx responses:%s(%d%%)" @@ -1042,13 +1033,19 @@ static int stats_dump_fields_html(struct buffer *out, 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 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, /* 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]);