Loading

Collect NGINX data with OpenTelemetry integrations (standalone)

Learn how to monitor your NGINX server by collecting logs and metrics with a standalone 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, then download the policy file and deploy it to your standalone Elastic Agent.

You’ll collect:

Important

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

  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. Use the port number 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.

To deploy an agent policy to a standalone Elastic Agent, start by creating the policy in Kibana. This approach allows you to configure all integration settings in advance, create an API key for the agent, and then generate a working agent policy, already populated with the output and integration details.

  1. Create an agent policy in Kibana

    1. In Kibana, find Fleet in the navigation menu or use the global search field.

    2. Go to Agent policies, then create a new agent policy (for example, nginx-telemetry-standalone).

      For detailed steps, refer to Create a standalone Elastic Agent policy.

      Note

      You don't need to enroll any agents to this policy. You'll download the policy file and deploy it manually to your standalone Elastic Agent.

  2. Configure log collection with the Nginx integration

    1. In Kibana, find Integrations in the navigation menu or use the global search field.

    2. Search for "nginx", then select the Nginx integration.

    3. Select Add Nginx, then configure the integration. Log collection from NGINX instances is enabled by default.

      1. Confirm the Paths fields for access and error logs match your NGINX configuration.
      2. Turn off Collect metrics from Nginx instances. In this tutorial, you'll use the OpenTelemetry input package for metrics collection.
    4. In the Where to add this integration? section, select Existing hosts.

    5. Select the agent policy you created for your standalone agent (for example, nginx-telemetry-standalone).

    6. Select Save and continue.

    For more details, refer to Add an integration to an Elastic Agent policy.

  3. Configure metrics collection with the NGINX OpenTelemetry input package

    1. In Kibana, go to Integrations.

    2. Select Display beta integrations (the NGINX OpenTelemetry packages are in technical preview).

    3. Search for "nginx", then select NGINX OpenTelemetry Input Package.

    4. Select Add NGINX OpenTelemetry Input Package, then configure the integration. NGINX OpenTelemetry Input is enabled by default.

      1. Select Change defaults, then expand Advanced options.
      2. Set the data stream type to Metrics.
      3. Set endpoint to your NGINX stub_status URL (for example, http://localhost:80/status).
    5. In the Where to add this integration? section, select Existing hosts.

    6. Select the agent policy you created for your standalone agent (for example, nginx-telemetry-standalone).

    7. Select Save and continue.

    Note

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

  4. Download the standalone policy

    1. In Kibana, go to FleetAgents, then click Add agent.
    2. Select the agent policy you created (for example, nginx-telemetry-standalone).
    3. Select Run standalone.
    4. Select Create API key to generate an API key and use it directly in the policy configuration.
    5. Select Download policy to download the policy file (elastic-agent.yml).
    6. Replace the elastic-agent.yml on the host where the Elastic Agent is installed with the generated policy file.

    The downloaded policy includes the default Elasticsearch host address and port. You can modify the policy to update the Elasticsearch connection details and the API key, or to adjust any integration-specific settings for your environment.

    For more details on customizing standalone policies, refer to Create a standalone Elastic Agent policy.

  5. Deploy the policy to your standalone Elastic Agent

    1. Copy the downloaded elastic-agent.yml policy file to the Elastic Agent installation directory on your Linux host (typically /opt/Elastic/Agent/).

    2. Start the Elastic Agent using the standalone policy:

      sudo systemctl start elastic-agent
      		

After you deploy the agent policy to your standalone Elastic Agent, validate that both the ECS-based logs and the OTel-based metrics are flowing in.

  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 by 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 is provided by the NGINX OpenTelemetry Assets content package, installed automatically when data is ingested through the NGINX OpenTelemetry Input Package.