Collect nginx logs and metrics with a hybrid standalone Elastic Agent
Follow this guide to learn how to configure a standalone Elastic Agent on a Linux host to 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
- An Observability project. To learn more, refer to Create an Observability project.
- A user with the Admin role or higher required to onboard system logs and metrics. To learn more, refer to User roles and privileges.
- Elastic Agent 9.2 or later installed on a Linux host.
- nginx installed on a 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 or higher—required to onboard system logs and metrics. To learn more, refer to User roles and privileges.
- Elastic Agent 9.2 or later installed on a Linux host.
- nginx installed on a 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- Replace the port number with the port specified in the
listendirective in the nginx configuration.
If the endpoint returns data, you are ready to set up Elastic Agent.
- Replace the port number with the port specified in the
For more details, refer to Configuring NGINX for Metric Collection.
TODO
After you apply the policy changes, validate both the ECS-based logs and the OTel-based metrics.
-
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 with 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 becomes available with the NGINX OpenTelemetry Assets content package, which is automatically installed when data is ingested trough the NGINX OpenTelemetry Input Package integration.