Monitor your NGINX Plus servers running on a host using the OpenTelemetry Collector to send metrics and telemetry data to New Relic.
This integration leverages the OpenTelemetry prometheusreceiver and nginx-prometheus-exporter to monitor your NGINX Plus performance metrics, connection statistics, and server health. The rich HTTP API in NGINX Plus provides significantly more detailed metrics compared to the basic stub status module in standard NGINX.
Expected output: HTTP/2 405 (method not allowed is expected)
Step 1: Configure NGINX Plus
Configure and enable the HTTP API module to expose metrics from your NGINX Plus server.
Add the HTTP API configuration to your nginx.conf file. Typically add this within the http block:
server{
listen8080;
server_name localhost;
location /api{
api write=on;
# Restrict access as needed
allow 127.0.0.1;
deny all;
}
}
After updating nginx.conf, test and reload the service:
bash
$
sudo nginx -t&&sudo nginx -s reload
Confirm the API endpoint path (including version) exposed in your configuration. Record the full API endpoint path (without the leading slash) and the port that serves it. Common defaults are api/9 on port 8080.
Use curl to confirm your API endpoint is reachable:
Save the file and ensure the otelcol-contrib system user can read it.
By default, the configuration collects only core metrics (connections, HTTP requests, and SSL). To enable additional metric categories like server zones, location zones, or cache metrics:
Identify the metrics you want to enable from the metrics list below. Note which category they belong to (e.g., HTTP Server Zones, Location Zones, Cache).
Move the corresponding metric prefix from exclude to include in the filter/nginx_metrics processor.
Example: Enable HTTP Server Zones metrics
Find this line in the exclude section:
filter/nginx_metrics:
metrics:
include:
# existing include metrics
exclude:
match_type: regexp
metric_names:
-"nginxplus_server_.*"
Move it to the include section:
filter/nginx_metrics:
metrics:
include:
match_type: regexp
metric_names:
-"nginxplus_connections_.*"
-"nginxplus_http_requests_.*"
-"nginxplus_ssl_.*"
-"nginxplus_server_.*"# Added to enable server zone metrics
exclude:
match_type: regexp
metric_names:
# Remove "nginxplus_server_.*" from here
-"nginxplus_location_zone_.*"
-"nginxplus_cache_.*"
# ... rest of exclude list
Restart the collector after making changes:
bash
$
sudo systemctl restart otelcol-contri.service
Step 3: Set environment variables for the collector
Inject your New Relic and OTLP endpoint into the collector service so the exporter can authenticate.
Write environment.conf with your OTLP endpoint. Replace YOUR_LICENSE_KEY with the New Relic license key and YOUR_OTLP_ENDPOINT with the appropriate endpoint for your region. Refer to the OTLP endpoint configuration documentation to select the right endpoint.
Extend your collector configuration to include access and error logs if you want log events alongside metrics.
Configure NGINX Plus log format
Before forwarding logs, configure NGINX Plus to use a structured log format. Refer to the NGINX logging documentation for guidance on configuring access and error logs.
Configure the OpenTelemetry Collector for log forwarding
Note the full paths to your NGINX access and error log files. Defaults are usually /var/log/nginx/access.log and /var/log/nginx/error.log.
Update /etc/otelcol-contrib/config.yaml to add a filelog receiver and log pipeline:
Select Dashboards, and click NGINX OTel overview dashboard.
In the popup window, select your account.
Click View dashboard, and see your NGINX Plus data in New Relic.
The NGINX Plus metrics are attached to the Metricevent type. You can query this data for troubleshooting purposes or to create custom charts and dashboards.
Metrics collected
The OpenTelemetry Collector scrapes metrics from the NGINX Prometheus exporter, which exposes NGINX Plus HTTP API metrics in Prometheus format.
Total number of bytes returned from stale cache hits
Sum
nginxplus_cache_updating_responses
Total number of cache hits while cache is updating
Sum
nginxplus_cache_updating_bytes
Total number of bytes returned from cache while cache is updating
Sum
nginxplus_cache_revalidated_responses
Total number of cache revalidations
Sum
nginxplus_cache_revalidated_bytes
Total number of bytes returned from cache revalidations
Sum
nginxplus_cache_miss_responses
Total number of cache misses
Sum
nginxplus_cache_miss_bytes
Total number of bytes returned from cache misses
Sum
nginxplus_cache_expired_responses
Total number of cache hits with expired TTL
Sum
nginxplus_cache_expired_bytes
Total number of bytes returned from cache hits with expired TTL
Sum
nginxplus_cache_expired_responses_written
Total number of cache hits with expired TTL written to cache
Sum
nginxplus_cache_expired_bytes_written
Total number of bytes written to cache from cache hits with expired TTL
Sum
nginxplus_cache_bypass_responses
Total number of cache bypasses
Sum
nginxplus_cache_bypass_bytes
Total number of bytes returned from cache bypasses
Sum
nginxplus_cache_bypass_responses_written
Total number of cache bypasses written to cache
Sum
nginxplus_cache_bypass_bytes_written
Total number of bytes written to cache from cache bypasses
Sum
Attribute
Description
Example Values
server_zone
The name of the server zone (applies to HTTP Server Zones metrics)
example.com, api.example.com
code
HTTP response status code (applies to response metrics)
1xx, 2xx, 3xx, 4xx, 5xx, 200, 404, 500
location_zone
The name of the location zone
/api, /images, /static
cache
The name of the cache
my_cache, static_cache
nginx.server.endpoint
The NGINX Plus API endpoint URL
http://localhost:8080/api
nginx.deployment.name
A unique name to identify this NGINX Plus deployment
production-web-01, staging-api
nginx.display.name
A display-friendly name combining "server" prefix with deployment name
server:production-web-01
host.name
The hostname of the system where NGINX Plus is running
web-server-01.example.com
host.id
The unique identifier of the host system
i-1234567890abcdef0
logtype
The type of log being collected (applicable to logs only). Used by New Relic's built-in parsing rules. This attribute is only available when log forwarding is enabled.