NGINX Opentelemetry Instrumentation

This document contains instructions on how to set up OpenTelemetry instrumentation in your NGINX Web Servers and send Traces, Metrics and Logs to SigNoz.

Send traces to SigNoz Cloud

Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.

From VMs, there are two ways to send data to SigNoz Cloud.

Send traces directly to SigNoz cloud

Step 1 : Install NGINX module

apt-get update && apt-get install -y nginx-otel-module

Step 2: Configure NGINX

Add the following to top of your nginx.conf file, this will load the installed module.

load_module modules/ngx_http_opentelemetry_module.so;

http {
  opentelemetry_config /etc/nginx/opentelemetry_config.yaml;
}

Step 3: Make OpenTelemetry configuration file

Modify the /etc/nginx/opentelemetry_config.yaml with following:

opentelemetry_config.yaml
service_name: <service_name>
sampler:
  type: always_on
exporter:
  otlp:
    endpoint: https://ingest.<region>.signoz.cloud:443/v1/traces
    headers:
      signoz-access-token: <your-ingestion-key>
  • Set the <region> to match your SigNoz Cloud region
  • Replace <your-ingestion-key> with your SigNoz ingestion key
  • <service_name> is name of your service

Step 4: Restart NGINX

Restart nginx using the below command:

systemctl restart nginx

The traces should start getting generated.

Send traces via OTel Collector binary

Step 1. Install OTel Collector binary

OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes.

You can find instructions to install OTel Collector binary here in your VM.

Step 2 : Install NGINX module

apt-get update && apt-get install -y nginx-otel-module

Step 3: Configure NGINX

Add the following to top of your nginx.conf file, this will load the installed module.

load_module modules/ngx_http_opentelemetry_module.so;

http {
  opentelemetry_config /etc/nginx/opentelemetry_config.yaml;
}

Step 4: Make OpenTelemetry configuration file

Modify the /etc/nginx/opentelemetry_config.yaml with following:

opentelemetry_config.yaml
service_name: <service_name>
sampler:
  type: always_on
exporter:
  otlp:
    endpoint: http://localhost:4317
  • <service_name> is name of your service

Step 5: Restart NGINX

Restart nginx using the below command:

systemctl restart nginx

The traces should start getting generated.

Sample NGINX Application

We have included a sample NGINX Server at Sample NGINX Server Github Repo

Monitor NGINX Logs

Follow this documentation for monitoring NGINX logs.

Was this page helpful?