nginx_vts_upstream_requests_total not including stale requests
When checking the prometheus status I see that there were 6 requests which were marked 'stale':
nginx_vts_cache_requests_total{cache_zone="nginx_cache",status="stale"} 6
This means that the client gets a cached page, but nginx is updating the file in the background (=request to the upstream). However, when checking the nginx_vts_upstream_requests_total I see the following:
nginx_vts_upstream_requests_total{upstream="wcmcontent-l.kbc.be",backend="10.45.0.200:443",code="1xx"} 0
nginx_vts_upstream_requests_total{upstream="wcmcontent-l.kbc.be",backend="10.45.0.200:443",code="2xx"} 2
nginx_vts_upstream_requests_total{upstream="wcmcontent-l.kbc.be",backend="10.45.0.200:443",code="3xx"} 0
nginx_vts_upstream_requests_total{upstream="wcmcontent-l.kbc.be",backend="10.45.0.200:443",code="4xx"} 1
nginx_vts_upstream_requests_total{upstream="wcmcontent-l.kbc.be",backend="10.45.0.200:443",code="5xx"} 0
So stale updates are not counted toward upstream requests while I would expect them to be counted
@YentlFrickx Nginx stale cache updates in background with subrequest as below. https://github.com/nginx/nginx/commit/8644d9491ad3c0eb16bcda1d452aba326e1f4dae
We assume that it could be logged to enable to log_subrequest as the code said
https://github.com/nginx/nginx/blob/6bdfd58f2660c394306ef34fe825d2f02f5ba813/src/http/ngx_http_request.c#L2571-L2582
I had confirmed that the official nginx document said Enables or disables logging of subrequests into [access_log](https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log).
https://nginx.org/en/docs/http/ngx_http_core_module.html#log_subrequest
So that status_handler hooks after NGX_HTTP_LOG_PHASE to obtain the various status to be recorded by log_module in LOG_PHASE.
https://github.com/vozlt/nginx-module-vts/blob/bd338835463811fe0221db858d865269952aaed9/src/ngx_http_vhost_traffic_status_module.c#L748-L753
https://nginx.org/en/docs/dev/development_guide.html#http_phases
Thus, we could not obtain some subrequest status unless we set it on log_subrequest.