Ingress-nginx: [nginx] help with setting up metrics collection with Prometheus

Created on 17 Mar 2017  路  2Comments  路  Source: kubernetes/ingress-nginx

Version: 0.9.0-beta.3

I deployed nginx ingress controller (as a DaemonSet) and configued a customer ConfigMap with enable-vts-status: true

In the controller log, I can see the following message:

2017-03-17T21:18:44.557253546Z I0317 21:18:44.557029       7 metrics.go:34] changing prometheus collector from  to vts

But at this point I'm not sure how to proceed, how should the Controller be configured to provide a scrape target for Prometheus ? I understand that this is implemented internally, but I don't understand how to configure it.

Here's my DaemonSet yaml:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  labels:
    name: nginx-ingress-lb
  name: nginx-ingress-lb
  namespace: kube-system
spec:
  selector:
    matchLabels:
      name: nginx-ingress-lb
  template:
    metadata:
      labels:
        name: nginx-ingress-lb
    spec:
      containers:
      - args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --udp-services-configmap=$(POD_NAMESPACE)/nginx-ingress-lb-udp-cm
        - --tcp-services-configmap=$(POD_NAMESPACE)/nginx-ingress-lb-tcp-cm
        - --configmap=$(POD_NAMESPACE)/nginx-ingress-lb-conf
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.3
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: nginx-ingress-lb
        ports:
        - containerPort: 80
          hostPort: 80
          protocol: TCP
        - containerPort: 443
          hostPort: 443
          protocol: TCP
        - containerPort: 5353
          hostPort: 55353
          protocol: UDP
        - containerPort: 5353
          hostPort: 55353
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        terminationMessagePath: /dev/termination-log
      dnsPolicy: ClusterFirst
      nodeSelector:
        node_type: worker
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 60

and here's my ConfigMap:

apiVersion: v1
data:
  enable-vts-status: "true"
kind: ConfigMap
metadata:
  name: nginx-ingress-lb-conf
  namespace: kube-system

Most helpful comment

Perfect! exactly what I was missing 馃憤 Thanks.

I added the following to my DaemonSet metadata and it works:

      annotations:
        prometheus.io/port: "10254"
        prometheus.io/scrape: "true"

Perhaps a quick note about this in the documentation ?

All 2 comments

@dannyk81 the prometheus metrics are exposed in port 10254 and path /metrics

Perfect! exactly what I was missing 馃憤 Thanks.

I added the following to my DaemonSet metadata and it works:

      annotations:
        prometheus.io/port: "10254"
        prometheus.io/scrape: "true"

Perhaps a quick note about this in the documentation ?

Was this page helpful?
0 / 5 - 0 ratings