NGINX
Monitor NGINX web servers and reverse proxies, including request throughput, connection states, and dropped connections, with the OpenTelemetry Collector NGINX receiver.
Overview
NGINX is an open-source web server, reverse proxy, and load balancer. It serves static content, terminates TLS, and routes traffic to upstream applications for a large share of the web, often as the first hop every request passes through.
Because NGINX sits in front of everything else, a problem there shows up as a problem everywhere: connections that pile
up in the reading or writing state point to slow clients or slow upstreams, and connections that are accepted but not
handled mean NGINX has run out of worker connections. The OpenTelemetry Collector's NGINX receiver polls the
stub_status endpoint and reports request and connection metrics to Dash0, without any agent on the NGINX host.
Running NGINX as a Kubernetes ingress controller? Use the Ingress-NGINX integration instead, which collects per-ingress request, latency, and status code metrics.
Use Cases
- Monitor request throughput per NGINX instance to spot traffic spikes and drops.
- Track connections by state (reading, writing, waiting) to tell slow clients and slow upstreams apart from idle keepalive connections.
- Detect dropped connections, which NGINX accepts but cannot handle once
worker_connectionsis exhausted. - Analyze requests per connection to understand how well clients reuse keepalive connections.
- Trace individual requests through NGINX into your upstream services with the NGINX OpenTelemetry module.
Setup
Overview
The OpenTelemetry Collector's NGINX receiver periodically requests the status page of the
ngx_http_stub_status_module and converts it into
metrics. The collector then forwards these metrics to Dash0.
The receiver reports four metrics:
nginx.requests: total number of client requests.nginx.connections_accepted: total number of accepted client connections.nginx.connections_handled: total number of handled connections. This equalsnginx.connections_acceptedunless NGINX hits a resource limit such asworker_connections.nginx.connections_current: current connections, broken down by thestateattribute intoactive,reading,writing, andwaiting.activeis the sum of the other three.
Optionally, the NGINX OpenTelemetry module adds a trace for every request, so you can follow requests from NGINX into your upstream services (see Collect Traces).
Prerequisites
Before setting up NGINX monitoring, ensure:
- NGINX is built with
ngx_http_stub_status_module. Check withnginx -V 2>&1 | grep -o with-http_stub_status_module. The official NGINX packages and container images include it. - The collector can reach the NGINX status endpoint over HTTP.
- The collector runs the OpenTelemetry Collector Contrib distribution , or a custom distribution that includes the NGINX receiver.
You'll need an OpenTelemetry Collector deployed. Consider using:
Enable the Status Endpoint
Add a location that serves stub_status to your NGINX configuration. Restrict access to it, because it reveals
traffic information about your server:
server {
listen 8080;
location /status {
stub_status;
access_log off;
allow 127.0.0.1;
allow 10.0.0.0/8; # the network your collector runs in
deny all;
}
}Reload NGINX and confirm the endpoint responds:
nginx -s reload
curl http://localhost:8080/statusThe output looks like this:
Active connections: 17
server accepts handled requests
1137 1137 19742
Reading: 0 Writing: 1 Waiting: 16Collector Configuration
Add the NGINX receiver to your OpenTelemetry Collector configuration and wire it into a metrics pipeline:
receivers:
nginx:
endpoint: http://nginx:8080/status
collection_interval: 10s
service:
pipelines:
metrics:
receivers: [nginx]Configuration Options
endpoint(required): URL of thestub_statuspage. Default:http://localhost:80/status.collection_interval: How often to poll the status page. Default:10s.initial_delay: Delay before the first collection. Default:1s.metrics: Enable or disable individual metrics. All four metrics are enabled by default.
The receiver also accepts the standard HTTP client settings, such as timeout, headers, and tls, which you need if
the status page is served over HTTPS or behind authentication.
For all available options, see the NGINX receiver documentation .
Monitoring Several NGINX Instances
The receiver does not add any attribute that identifies the NGINX server it scraped. Its metrics carry only the resource
attributes your collector adds, such as host.name, so two NGINX servers scraped by the same collector look identical
in Dash0.
To tell them apart, give each server its own receiver and pipeline, and set service.name with a resource processor:
receivers:
nginx/web:
endpoint: http://web-nginx:8080/status
nginx/api:
endpoint: http://api-nginx:8080/status
processors:
resource/web:
attributes:
- key: service.name
value: web-nginx
action: upsert
resource/api:
attributes:
- key: service.name
value: api-nginx
action: upsert
service:
pipelines:
metrics/nginx-web:
receivers: [nginx/web]
processors: [resource/web]
metrics/nginx-api:
receivers: [nginx/api]
processors: [resource/api]In Kubernetes, the receiver creator can start an NGINX receiver for every matching pod and adds the pod's Kubernetes attributes automatically.
Collect Traces (Optional)
The NGINX OpenTelemetry module (ngx_otel_module) creates a span for
every request NGINX handles and propagates the trace context to your upstream services. The nginx:*-otel container
images ship with the module. Load it and point it at your collector's OTLP gRPC endpoint:
load_module modules/ngx_otel_module.so;
http {
otel_exporter {
endpoint otel-collector:4317;
}
otel_service_name nginx;
otel_trace on;
otel_trace_context propagate;
# ... your server blocks
}The collector needs an otlp receiver in a traces pipeline to accept these spans.
Verification
- Check the collector logs for errors from the
nginxreceiver. - Navigate to the Metrics Explorer in Dash0.
- Search for metrics with the prefix
nginx.*. - Confirm the four metrics are visible:
nginx.requests,nginx.connections_accepted,nginx.connections_handled, andnginx.connections_current.
