Download and Install the NGINX Agent

Do the following:
  1. Download the NGINX Agent from GitHub.
  2. Extract and install the agent to /opt.
    CODE
    tar -xf opentelemetry-webserver-sdk-x64-linux.tgz -C /opt
    cd /opt/opentelemetry-webserver-sdk/
    ./install.sh
  3. Copy the conf/nginx/opentelemetry_module.conf file to /opt/. See Sample OpenTelemetry Module Configuration File.
  4. Edit the directives values according to your deployment environment. For example, NginxModuleOtelExporterEndpoint must point to the Collector URL.
  5. Edit the nginx.conf file to provide a reference to opentelemetry_module.conf and shared library. See Sample NGINX Configuration File.
  6. Follow the below command sequence and location while referring to conf/nginx/nginx.conf.
    CODE
    load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/
    ngx_http_opentelemetry_module.so;
    include /opt/opentelemetry_module.conf;
  7. Before you start the NGINX Agent, update dependencies LD_LIBRARY_PATH to load OpenTelemetry.
    CODE
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/opentelemetry-webserver-sdk/sdk_lib/lib

Sample OpenTelemetry Module Configuration File

CODE
NginxModuleEnabled ON;
#NginxModule Otel Exporter details
NginxModuleOtelSpanExporter otlp;
NginxModuleOtelExporterEndpoint docker.for.mac.localhost:4317;
# SSL Certificates
#NginxModuleOtelSslEnabled ON
#NginxModuleOtelSslCertificatePath
#NginxModuleOtelSpanProcessor Batch
#NginxModuleOtelSampler AlwaysOn
#NginxModuleOtelMaxQueueSize 1024
#NginxModuleOtelScheduledDelayMillis 3000
#NginxModuleOtelExportTimeoutMillis 30000
#NginxModuleOtelMaxExportBatchSize 1024
NginxModuleServiceName DemoService;
NginxModuleServiceNamespace DemoServiceNamespace;
NginxModuleServiceInstanceId DemoInstanceId;
NginxModuleResolveBackends ON;
NginxModuleTraceAsError ON;
#NginxModuleWebserverContext DemoService DemoServiceNamespace DemoInstanceId
#NginxModuleSegmentType custom
#NginxModuleSegmentParameter 15,1,6,7

Sample NGINX Configuration File

CODE
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/
ngx_http_opentelemetry_module.so;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /opt/opentelemetry_module.conf;
}