Skip to content

Metrics ​

With metrics.enabled the pod gets a sidecar running the NGINX Prometheus exporter. It reads NGINX's status page over loopback and serves the result as Prometheus metrics on port 9113, through a Service of its own.

yaml
metrics:
  enabled: true
  serviceMonitor:
    enabled: true     # needs the Prometheus Operator
ParameterDescriptionDefault
metrics.enabledRun the exporter sidecarfalse
metrics.image.registry, .repository, .tagThe exporter imagedocker.io, nginx/nginx-prometheus-exporter, a pinned tag
metrics.portPort of NGINX's status page; empty is the HTTP container port""
metrics.extraArgsFurther arguments for the exporter[]
metrics.containerPorts.metricsThe exporter's container port9113
metrics.service.portThe metrics Service's port9113
metrics.service.annotationsAnnotations of the metrics Serviceprometheus.io/scrape: "true" and the port
metrics.resourcesPreset, metrics.resourcesThe sidecar's resourcesnano
metrics.serviceMonitor.enabledCreate a ServiceMonitor for the Prometheus Operatorfalse
metrics.serviceMonitor.namespace, .jobLabel, .interval, .scrapeTimeout, .relabelings, .metricRelabelings, .honorLabelsSettings of the ServiceMonitor
metrics.serviceMonitor.labels, .selectorLabels of the ServiceMonitor, such as the ones your Prometheus selects ServiceMonitors by{}

The chart's NetworkPolicy, which is on by default, admits the exporter's port along with the pod's other ports, and from the same sources: any, unless networkPolicy.allowExternal is false. Released chart versions up to 7.1.408 did not list it, and metrics.serviceMonitor.metricRelabelings and .selector had no effect there. On such a version, where the cluster enforces network policies, admit the scrape yourself, and only from where Prometheus runs; here that is the namespace monitoring:

yaml
networkPolicy:
  extraIngress:
    - ports:
        - port: 9113
      from:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: monitoring

Without the Prometheus Operator, the Service's prometheus.io/scrape annotations let a Prometheus that discovers targets by annotation find the exporter.

The exporter reports on NGINX: connections and requests. Findings on the site's files are a separate set of metrics, from the file-integrity watcher, which has a ServiceMonitor and alert rules of its own.

Distributed under the Apache-2.0 license. WordPress, NGINX, Bitnami and other names are trademarks of their owners; this project is not affiliated with or endorsed by them.