Loading

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:

  • 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.

  1. Make sure the ngx_http_stub_status_module module is enabled.

  2. In your nginx configuration file (for example, /etc/nginx/nginx.conf), add or modify the location block in the server { ... } block with the following:

    location = /status {
      stub_status;
    }
    		
  3. Save the configuration and restart nginx:

    sudo systemctl restart nginx
    		
  4. Verify that the endpoint is active:

    curl http://localhost:80/status
    		
    1. Replace the port number with the port specified in the listen directive in the nginx configuration.

    If the endpoint returns data, you are ready to set up Elastic Agent.

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.

  1. Validate the log collection

    1. In Kibana, go to Discover, then filter the results using the KQL search bar.

    2. Search for nginx data stream datasets such as nginx.access and nginx.error, or enter:

      data_stream.dataset : "nginx.access" or "nginx.error"
      		
    3. Go to Dashboards, then select [Logs Nginx] Access and error logs to view the dashboard installed with the Nginx integration.

  2. 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.