diff --git a/include/types/counters.h b/include/types/counters.h index 79dd6d437..189854874 100644 --- a/include/types/counters.h +++ b/include/types/counters.h @@ -56,6 +56,8 @@ struct fe_counters { long long comp_rsp; /* number of compressed responses */ unsigned int rps_max; /* maximum of new HTTP requests second observed */ long long rsp[6]; /* http response codes */ + long long cache_lookups;/* cache lookups */ + long long cache_hits; /* cache hits */ } http; } p; /* protocol-specific stats */ }; @@ -105,6 +107,8 @@ struct be_counters { long long comp_rsp; /* number of compressed responses */ unsigned int rps_max; /* maximum of new HTTP requests second observed */ long long rsp[6]; /* http response codes */ + long long cache_lookups;/* cache lookups */ + long long cache_hits; /* cache hits */ } http; } p; /* protocol-specific stats */ }; diff --git a/include/types/stats.h b/include/types/stats.h index c3b9fc8fc..ec29c786b 100644 --- a/include/types/stats.h +++ b/include/types/stats.h @@ -394,6 +394,8 @@ enum stat_field { ST_F_WREW, ST_F_CONNECT, ST_F_REUSE, + ST_F_CACHE_LOOKUPS, + ST_F_CACHE_HITS, /* must always be the last one */ ST_F_TOTAL_FIELDS diff --git a/src/cache.c b/src/cache.c index 74743f2b5..199b86563 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1389,6 +1389,11 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p if (s->txn->flags & TX_CACHE_IGNORE) return ACT_RET_CONT; + if (px == strm_fe(s)) + HA_ATOMIC_ADD(&px->fe_counters.p.http.cache_lookups, 1); + else + HA_ATOMIC_ADD(&px->be_counters.p.http.cache_lookups, 1); + shctx_lock(shctx_ptr(cache)); res = entry_exist(cache, s->txn->cache_hash); if (res) { @@ -1402,6 +1407,11 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p appctx->ctx.cache.entry = res; appctx->ctx.cache.next = NULL; appctx->ctx.cache.sent = 0; + + if (px == strm_fe(s)) + HA_ATOMIC_ADD(&px->fe_counters.p.http.cache_hits, 1); + else + HA_ATOMIC_ADD(&px->be_counters.p.http.cache_hits, 1); return ACT_RET_CONT; } else { shctx_lock(shctx_ptr(cache)); diff --git a/src/stats.c b/src/stats.c index 823502ff3..3ee168912 100644 --- a/src/stats.c +++ b/src/stats.c @@ -230,6 +230,8 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = { [ST_F_WREW] = "wrew", [ST_F_CONNECT] = "connect", [ST_F_REUSE] = "reuse", + [ST_F_CACHE_LOOKUPS] = "cache_lookups", + [ST_F_CACHE_HITS] = "cache_hits", }; /* one line of info */ @@ -724,6 +726,8 @@ static int stats_dump_fields_html(struct buffer *out, "