<p>I want to get my nginx-ingress metrics to be added in Prometheus so I can see my app logs to be shown in loki.  However, I have not had much success.  I have been following this guide <a href="https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/04-setup-prometheus-stack/README.md#step-3---creating-the-nginx-backend-services" rel="nofollow noreferrer">here</a> but I want to do this for nginx-ingress instead, the guide is for ambassador ingress.</p>
<p>Nginx-Ingress installed using the following command:</p>
<pre><code>NGINX_CHART_VERSION=&quot;4.0.6&quot;;
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --version &quot;$NGINX_CHART_VERSION&quot; --namespace ingress-nginx -f &quot;03-setup-ingress-controller/assets/manifests/nginx-values-v${NGINX_CHART_VERSION}.yaml&quot;  --set controller.metrics.enabled=true  --set-string controller.podAnnotations.&quot;prometheus\.io/scrape&quot;=&quot;true&quot;  --set-string controller.podAnnotations.&quot;prometheus\.io/port&quot;=&quot;10254&quot;
</code></pre>
<p>So I have my nginx-ingress metrics exposed in my k8 cluster as you can see:</p>
<pre><code>kubectl get svc -n ingress-nginx                                    
NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.245.57.3      &lt;REDACTED&gt;   80:31150/TCP,443:31740/TCP   9d
ingress-nginx-controller-admission   ClusterIP      10.245.186.61    &lt;none&gt;            443/TCP                      9d
ingress-nginx-controller-metrics     ClusterIP      10.245.240.243   &lt;none&gt;            10254/TCP                    20h
</code></pre>
<p>I did a Helm upgrade with a values file that contains my ingress-nginx-controller-metrics :</p>
<pre><code> HELM_CHART_VERSION=&quot;27.2.1&quot;;
helm upgrade kube-prom-stack prometheus-community/kube-prometheus-stack \
--version &quot;${HELM_CHART_VERSION}&quot;  --namespace monitoring  \ 
-f &quot;04-setup-prometheus-stack/assets/manifests/prom-stack-values-v${HELM_CHART_VERSION}.yaml&quot;
</code></pre>
<p>and I updated it with the values file to contains, customized from <a href="https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/04-setup-prometheus-stack/assets/manifests/prom-stack-values-v17.1.3.yaml" rel="nofollow noreferrer">git repo</a> config) as:</p>
<pre><code>## Starter Kit components service monito
  #
additionalServiceMonitors:
  - name: &quot;ingress-nginx-monitor&quot;
    selector:
      matchLabels:
        service: &quot;ingress-nginx-controller
    namespaceSelector:
      matchNames:
        - ingress-nginx
    endpoints:
      - port: &quot;ingress-nginx-controller-me
        path: /metrics
        scheme: http
</code></pre>
<p>However, when I check the Prometheus Targets I don't see the nginx ingress there.</p>

Katlock
<p>additionalServiceMonitors for the kube-prom-stack should be :</p>
<pre class="lang-yaml prettyprint-override"><code>    additionalServiceMonitors:
        - name: &quot;ingress-nginx-monitor&quot;
          selector:
            matchLabels:
              app.kubernetes.io/name: ingress-nginx
          namespaceSelector:
            matchNames:
              - ingress-nginx
          endpoints:
            - port: &quot;metrics&quot;
</code></pre>
