Collect NGINX data with OpenTelemetry integrations (Fleet-managed)
Learn how to monitor your NGINX server by collecting logs and metrics with a Fleet-managed Elastic Agent on Linux.
You'll use Kibana and Fleet to create an agent policy that combines both ECS-based integrations and OpenTelemetry input packages and apply it to your Fleet-managed Elastic Agent.
You'll collect:
- NGINX logs with Elastic's Nginx integration, based on the Elastic Common Schema (ECS)
- NGINX metrics with Elastic's NGINX OpenTelemetry Input Package, which uses the
nginxreceiverOpenTelemetry (OTel) Collector receiver
OpenTelemetry input packages are used with Fleet and Elastic Agent running in default mode. They cannot be used with an Elastic Agent running as an EDOT Collector (an agent in otel mode).
- An Observability project. To learn more, refer to Create an Observability project.
- A user with the Admin role. To learn more, refer to User roles and privileges.
- Elastic Agent 9.2 or later installed on a Linux host.
- NGINX installed on the Linux host.
- An Elasticsearch cluster for storing and searching your data, and Kibana for visualizing and managing your data.
- A user with the Admin role. To learn more, refer to User roles and privileges.
- Elastic Agent 9.2 or later installed on a Linux host.
- NGINX installed on the Linux host.
The nginxreceiver OTel Collector receiver needs an endpoint that exposes NGINX status metrics.
Make sure the
ngx_http_stub_status_modulemodule is enabled.In your NGINX configuration file (for example,
/etc/nginx/nginx.conf), add or modify thelocationblock in theserver { ... }block with the following:location = /status { stub_status; }Save the configuration and restart NGINX:
sudo systemctl restart nginxVerify that the endpoint is active:
curl http://localhost:80/status- Use the port number specified in the
listendirective in the NGINX configuration.
If the endpoint returns data, you are ready to set up Elastic Agent.
- Use the port number specified in the
For more details, refer to Configuring NGINX for Metric Collection.
-
Create an agent policy and enroll an agent
In Kibana, find Fleet in the navigation menu or use the global search field.
Go to Agent policies, then create an agent policy (for example,
nginx-telemetry), or select an existing policy you want to use to collect NGINX telemetry.Add an Elastic Agent running version 9.2 or later to the policy.
For detailed steps, refer to Install Fleet-managed Elastic Agents.
-
Configure log collection with the Nginx integration
In Kibana, find Integrations in the navigation menu or use the global search field.
Search for "nginx", then select the Nginx integration.
Select Add Nginx, then configure the integration. Log collection from NGINX instances is enabled by default.
- Confirm the Paths fields for access and error logs match your NGINX configuration.
- Turn off Collect metrics from Nginx instances. In this tutorial, you’ll use the OpenTelemetry input package for metrics collection.
In the Where to add this integration? section, select Existing hosts.
Select the agent policy to which you want to add the integration (for example,
nginx-telemetry).Select Save and continue.
For more details, refer to Add an integration to an Elastic Agent policy.
-
Configure metrics collection with the NGINX OpenTelemetry input package
In Kibana, go to Integrations.
Select Display beta integrations (the NGINX OpenTelemetry packages are in technical preview).
Search for "nginx", then select NGINX OpenTelemetry Input Package.
Select Add NGINX OpenTelemetry Input Package, then configure the integration. NGINX OpenTelemetry Input is enabled by default.
- Select Change defaults, then expand Advanced options.
- Set the data stream type to Metrics.
- Set endpoint to your NGINX
stub_statusURL (for example,http://localhost:80/status).
In the Where to add this integration? section, select Existing hosts.
Select the agent policy you used for the NGINX log collection (for example,
nginx-telemetry).Select Save and continue.
NoteThe NGINX OpenTelemetry Assets content package is installed automatically when data is ingested through the NGINX OpenTelemetry Input Package. You can find it in the Installed integrations list and use it to visualize OTel-based metrics.
After you apply the policy changes, validate that both the ECS-based logs and the OTel-based metrics are flowing in.
-
Validate the log collection
In Kibana, go to Discover, then filter the results using the KQL search bar.
Search for NGINX data stream datasets such as
nginx.accessandnginx.error, or enter:data_stream.dataset : "nginx.access" or "nginx.error"Go to Dashboards, then select [Logs Nginx] Access and error logs to view the dashboard installed by the Nginx integration.
-
Validate the metrics collection
Go to Dashboards, then select [Metrics Nginx OTEL] Overview to view the dashboard for visualizing OTel-based metrics.
This dashboard is provided by the NGINX OpenTelemetry Assets content package, installed automatically when data is ingested through the NGINX OpenTelemetry Input Package.