ingress-nginx icon indicating copy to clipboard operation
ingress-nginx copied to clipboard

Question: `nginx_ingress_controller_ingress_upstream_latency_seconds` DEPRECATED tag

Open Neah-Ko opened this issue 2 years ago • 3 comments

Hello, First of all, I apologize for not using issue template. It seems that kubernetes slack requires an account and the other templates were not suited.

Question: From that document

  • Why there is a deprecated flag on the nginx_ingress_controller_ingress_upstream_latency_seconds metric ?
  • What would be the deletion horizon ?

Context: I am trying to make a containerized app run on kubernetes with a 1 instance per user pattern. On demand from a web client, I instantiate a deployment+service+ingress that provides a unique url for the user to visit the app from a browser.

This instance should be cleaned up to salvage cluster resources when not needed anymore i.e. after some fixed time or user closes the tab/browser.

I have been advised to implement an operator to handle the end of lifecycle.

The first condition is pretty straightforward. However, detecting web app being closed from the kubernetes ecosystem has proven to be tricky.

Current workaround:

I made some experiments and found a "trick" using the nginx_ingress_controller_ingress_upstream_latency_seconds metric.

When app is opened in the browser

curl -s http://<host>:10254/metrics | grep 'instance' | grep 'nginx_ingress_controller_ingress_upstream_latency_seconds'

nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.5"} 0
nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.9"} 0
nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.99"} 0.001

After ~400s I closed the browser or ~600s I closed the tab

curl -s http://<host>:10254/metrics | grep 'instance' | grep 'nginx_ingress_controller_ingress_upstream_latency_seconds'

nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.5"} NaN
nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.9"} NaN
nginx_ingress_controller_ingress_upstream_latency_seconds{canary="",controller_class="k8s.io/ingress-nginx",{canary="",controller_class="k8s.io/ingress-nginx",controller_namespace="ingress-nginx",controller_pod="ingress-nginx-controller-uuid",ingress="instance",namespace="default",service="instance",quantile="0.99"} NaN

Notice: The end of each lines that presented latency values are turning to NaN.

This works perfectly for my use case (and so far is my only lead), as my operator could check the metrics in order to know it has to flush the deployment.

Now I realized that this was a deprecated feature. I couldn't find an issue describing why it got deprecated in this repo. So before I implement my solution it would be nice to have more info.

Thanks.

Neah-Ko avatar Oct 20 '23 15:10 Neah-Ko