Skip to content

No metrics on ingresses with server-snippet #13594

@isc30

Description

@isc30

Related to #3713:

When using server-snippet, there are no metrics generated. We have a bunch of ingresses without a backend and the traffic is not monitored there. Our use case is having multiple redirectors and proxy_pass defined like this.

Tried setting metrics-per-undefined-host: true and metrics-per-host: true without success.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: hello-world
  annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
      location ~* ^/$ {
        return 200 'hello world';
        add_header Content-Type text/plain;
      }
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - "hello.my.home"
  rules:
    - host: hello.my.home
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: dummy-svc
              port:
                number: 80

You can simulate some load with k6 or curl:

while true; do curl -s -o /dev/null -w "%{http_code}\n" https://hello.my.home/; done

This is the specific metric that we expect to have some data:

sum by (ingress) (irate(nginx_ingress_controller_requests[$__rate_interval]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.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