The OpenTelemetry Collector provides an integration with NGINX to ingest metrics. The Collector fetches metrics from the configured path in the NGINX receiver. From there the metrics are processed and exported to Cloud Observability.
To complete the integration, you will:
You’ve configured the Collector to export metric data to Cloud Observability.
The details of your configuration will vary with the infrastructure that you run. See the example for an integration using a Docker compose file.
Collecting metrics as shown in this example requires that you build NGINX with the stub_status
module, included in the build of the official Docker images.
Configure NGINX instances to provide status metrics by including something like the following in your nginx.conf
files.
1
2
3
4
5
6
7
8
9
server {
#
# ... additional configuration goes here ...
#
location /status {
stub_status;
allow all;
}
}
For more detail about configuring NGINX see the documentation of the stub status module, and more generally, NGINX documentation.
In the Collector configuration file, add NGINX as a receiver and set the following:
endpoint
: The endpoint ofcollection_interval
: Interval to internally sample the statistics endpoint. This value must be a string readable by Golang’s time.ParseDuration. Valid time units are ns
, us
(or µ
s), ms
, s
, m
, h
.1
2
3
4
receivers:
nginx:
endpoint: 'http://localhost:80/status'
collection_interval: 10s
The OpenTelemetry repo’s readme provides additional details about NGINX configuration.
This example collects metrics using a docker compose file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
services:
nginx:
image: nginx:1.19
configs:
- source: nginx_conf
target: /etc/nginx/conf.d/nginx.conf
otel-collector:
container_name: otel-collector
image: otel/opentelemetry-collector-contrib:0.51.0
environment:
LS_ACCESS_TOKEN: ${LS_ACCESS_TOKEN}
configs:
- source: collector_conf
target: /conf/collector.yml
command: ["--config=/conf/collector.yml"]
configs:
collector_conf:
file: ./collector.yml
nginx_conf:
file: ./nginx.conf
Once the NGINX receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.
You can validate that metrics are reporting to Cloud Observability on the Metrics details page in Settings.
In Cloud Observability, click Settings > Metric details.
Search for NGINX metric names.
See the receiver’s metadata file for a complete list of emitted metrics.
If needed, click on the metric to edit the description and how the units are displayed in Cloud Observability.
Use the Cloud Observability Terraform Provider to create a dashboard for the metrics.
For a more complete example that’s ready to run, see the NGINX integration in Cloud Observability OpenTelemetry Examples.
Updated Dec 1, 2022