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 Lightstep Observability.

To complete the integration, you will:

  • Configure NGINX to report metrics to the OpenTelemetry Collector
  • Configure the NGINX receiver for the Collector
  • Enable the integration by adding it to a pipeline

Prerequisites

You’ve configured the Collector to export metric data to Lightstep Observability.

Configure NGINX reporting

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.

Configure the Collector receiver

In the Collector configuration file, add NGINX as a receiver and set the following:

  • endpoint: The endpoint of
  • collection_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.

Example configuration with docker-compose

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     

Enable the Collector receiver

Once the NGINX receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.

Validate metrics are reporting to Lightstep

You can validate that the metrics are reporting to Lightstep from the Metric details section of the Project Settings page.

  1. Open the Project settings page and scroll to the Metric details section.

  2. Search for NGINX metric names. Search for metric

    See the receiver’s metadata file for a complete list of emitted metrics.

  3. If needed, click on the metric to edit the description and how the units are displayed in Lightstep.

Create a dashboard for the metrics

Use the Lightstep Terraform Provider to create a dashboard for the metrics.

Additional resources

For a more complete example that’s ready to run, see the NGINX integration in Lightstep OpenTelemetry Examples.