Expose upstream cache HIT/MISS as Prometheus metrics in F5 Ingress Controller

Title: Expose upstream cache HIT/MISS as Prometheus metrics in F5 NGINX Ingress Controller

Question:

Hi @hshannon

We run F5 NGINX Ingress Controller on Kubernetes and have upstream caching enabled for a VirtualServer.

Our NGINX access logs correctly expose the cache result using:

cache_status=$upstream_cache_status

For example, we see HIT and MISS in access logs. However, the Prometheus endpoint on port 9113 only exposes a total request metric:

nginx_ingress_nginx_http_requests_total{class="cms-gec-f5"} 340090

This metric has no labels for cache state, URI, host, status, or upstream.

Is there a supported way to expose upstream-cache metrics such as:

nginx_ingress_upstream_cache_requests_total{
  cache_status="HIT|MISS|BYPASS|EXPIRED|STALE",
  virtualserver="...",
  upstream="..."
}

Questions:

  1. Does F5 NGINX Ingress Controller expose $upstream_cache_status as a native Prometheus metric?
  2. Is this capability available only with NGINX Plus?

The NGINX Ingress Controller relies on the NGINX Prometheus Exporter to provide it’s built-in feature. You can see the list of available NGINX metrics in the repo: GitHub - nginx/nginx-prometheus-exporter: NGINX Prometheus Exporter for NGINX and NGINX Plus · GitHub.

If you are using the NGINX OSS version, the prometheus exporter would use the stub status module for the metrics instead of the NGINX Plus API which offers something like nginxplus_cache_hit_responses.

I don’t see the stub status currently returns cache-related metrics, but I will leave to others who are more familiar with the NGINX roadmap about any possible enhancement in the future.

Since you can already print the variable in the log, you might need to parse the NGINX log externally for your analytics if you are not using Plus.

Hello ,thanks for the update @hshannon
Could you please confirm: if we continue using the NGINX OSS version and do not use an NGINX Plus license, is there no supported native Prometheus metric for upstream cache HIT/MISS status?

In that case, is parsing $upstream_cache_status from NGINX access logs the recommended approach for building cache HIT/MISS dashboards and alerts?

Hi @Ashutosh_Pathania,

that is correct, with NGINX OSS, there are no native Prometheus metrics for upstream cache hit/miss status. This is currently a Plus only feature.

Parsing $upstream_cache_status from the access logs is currently the best way for OSS to build these dashboards and alerts.