All Products
Search
Document Center

Elasticsearch:Use Elastic Agent to collect Nginx log data

Last Updated:Aug 19, 2026

Elastic Agent provides a unified way to collect Nginx metrics and logs from your ECS instances and send them to your Elasticsearch cluster for centralized analysis. You can use Fleet to manage agent policies, deploy Elastic Agent to your hosts, and visualize Nginx data through Kibana dashboards.

Create an agent policy

Create an agent policy in Fleet to define how Elastic Agent collects data.

  1. In the Kibana console, go to Fleet > Agent policies.

  2. Click Create agent policy.

  3. Enter a name for the policy.

  4. Configure the policy settings as needed.

  5. Expand Advanced Options.

  6. Deselect Collect agent logs and Collect agent metrics.

  7. Click Create agent policy.

Note

Deselecting Collect agent logs and Collect agent metrics reduces unnecessary data collection when you only need Nginx metrics.

Add an Elastic Agent

Install Elastic Agent on your ECS instance and enroll it with Fleet Server.

  1. In the Kibana console, go to Fleet > Agents.

  2. Click Add Agent.

  3. Select the agent policy you created.

  4. Follow the on-screen instructions for your operating system.

  5. In the Install Fleet Server on a centralized host section, copy the installation command and run it on the first ECS instance. The following example shows a typical installation command. Replace the placeholder values (xxx) with the values generated in your Fleet setup:

curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.5.1-linux-x86_64.tar.gz
tar xzvf elastic-agent-8.5.1-linux-x86_64.tar.gz
cd elastic-agent-8.5.1-linux-x86_64
sudo ./elastic-agent install \
    --fleet-server-es=http://es-cn-xxx.elasticsearch.aliyuncs.com:9200 \
    --fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2Vydmxxxxxxxxxxxxx \
    --fleet-server-policy=e4b6f6b0-1ef9-11ee-xxx

View data

After Elastic Agent is installed and enrolled, you can view Nginx data in Kibana through dashboards or the Discover interface.

View Nginx data in dashboards

  1. In the Kibana console, go to Dashboard.

  2. Search for and select [Metrics Nginx] Overview.

  3. The dashboard contains the following three line chart panels: Total requests [Metrics Nginx], Processed requests [Metrics Nginx], and Heartbeat / Up [Metrics Nginx]. You can use the KQL search bar and the Nginx instance filter at the top to filter data.

View index data via Discover

  1. In the Kibana console, go to Discover.

  2. Select the data view, for example metrics-*, to view the collected Nginx metrics data.