<p>I'm using <a href="https://github.com/kubernetes/ingress-nginx" rel="noreferrer">ingress-nginx</a> as an Ingress controller for one of my services running over K8S (I'm using the nginx-0.20.0 release image with no specific metrics configurations in the K8S configmap the ingress-controller is using). </p>

<p>The nginx-ingress-controller pods are successfully scraped into my Prometheus server but all ingress metrics (e.g. <code>nginx_ingress_controller_request_duration_seconds_bucket</code>) show up with <code>path="/"</code> regardless of the real path of the handled request.</p>

<p>Worth noting that when I look at the ingress logs - the path is logged correctly.</p>

<p>How can I get the real path noted in the exported metrics?</p>

<p>Thanks!</p>

<p>The <code>Path</code> attribute in the NGINX metrics collected by prometheus derives from the Ingress definition yaml.</p>

<p>For example, if your ingress is:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: &lt;some-k8s-ingress-name&gt;
  namespace: &lt;some-k8s-namespace-name&gt;
spec:
  rules:
  - host: &lt;hostname&gt;
    http:
      paths:
      - backend:
          serviceName: &lt;some-k8s-service-name&gt;
          servicePort: &lt;some-port&gt;
        path: /
</code></pre>

<p>Then although NGINX will match any URL to your service, it'll all be logged under the path "<code>/</code>" (as seen <a href="https://github.com/kubernetes/ingress-nginx/blob/d74dea7585b7b26cf5a16ca9d7ac402b1e0cf8df/rootfs/etc/nginx/template/nginx.tmpl#L1010" rel="nofollow noreferrer">here</a>).</p>

<p>If you want metrics for a specific URL, you'll need to explicitly specify it like this (notice the ordering of rules):</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 annotations:
   kubernetes.io/ingress.class: nginx
 name: &lt;some-k8s-ingress-name&gt;
 namespace: &lt;some-k8s-namespace-name&gt;
spec:
 rules:
 - host: &lt;hostname&gt;
   http:
     paths:
     - backend:
         serviceName: &lt;some-k8s-service-name&gt;
         servicePort: &lt;some-port&gt;
       path: /more/specific/path
     - backend:
         serviceName: &lt;some-k8s-service-name&gt;
         servicePort: &lt;some-port&gt;
       path: /
</code></pre>
