Skip to content

cpu time metric is missing user-time, so the nginx_ingress_controller_nginx_process_cpu_seconds_total metric seems off #13453

@savar

Description

@savar

In the collector only the CPUSystemTime is being collected, while this is only half of the overall usage. The CPUUserTime is missing (or I miss the point, why only the SystemTime should be used).

This leads to completely different results if you check (using kube-prometheus-stack) as an example this:

Image

For reference, the ps output of the pod (to see, that there should be no real difference in both metrics, as the nginx process is the main consumer):

PID   USER     TIME  COMMAND
    1 www-data  0:00 /usr/bin/dumb-init -- /nginx-ingress-controller --publish-service=<namespace>/ingress-network-service-controller --election-id=ingress-network-service-leader --controller-class=k8s.io/nginx-network-service --ingress-class=nginx --configmap=<namespace>/ingress-network-service-controller --watch-namespace=<namespace> --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key --ingress-class-by-name=true --enable-metrics=true --update-status-on-shutdown=false
    7 www-data  7:37 /nginx-ingress-controller --publish-service=<namespace>/ingress-network-service-controller --election-id=ingress-network-service-leader --controller-class=k8s.io/nginx-network-service --ingress-class=nginx --configmap=<namespace>/ingress-network-service-controller --watch-namespace=<namespace> --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key --ingress-class-by-name=true --enable-metrics=true --update-status-on-shutdown=false
   27 www-data  0:00 nginx: master process /usr/bin/nginx -c /etc/nginx/nginx.conf
   32 www-data  1h09 nginx: worker process
   33 www-data  1h08 nginx: worker process
   34 www-data  1h08 nginx: worker process
   35 www-data  1h08 nginx: worker process
   36 www-data  1h08 nginx: worker process
   67 www-data  1h09 nginx: worker process
   93 www-data  1h10 nginx: worker process
  104 www-data  1h13 nginx: worker process
  148 www-data  0:13 nginx: cache manager process
  440 www-data  0:00 sh
  449 www-data  0:00 sh
  467 www-data  0:00 sh
  473 www-data  0:00 ps

It might be as simple as doing this:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions