Ingest logs, metrics, and uptime data with Elastic Agent

edit

Ingest logs, metrics, and uptime data with Elastic Agent

edit

This guide describes how to:

  • Set up Fleet
  • Send data to the Elastic Stack using Elastic Agent
  • Monitor logs and metrics from systems and services across your organization
  • Monitor the availability of your HTTP, TCP, and ICMP services using the Synthetics integration
  • Monitor Nginx logs and metrics using the Nginx integration

For feedback and questions, please contact us in the discuss forum.

Prerequisites
edit
  • You need Elasticsearch for storing and searching your data, and Kibana for visualizing and managing it. You can use our hosted Elasticsearch Service on Elastic Cloud (recommended), or self-manage the Elastic Stack on your own hardware.

    Here’s what you need for each deployment type:

    • Access to a deployment of our hosted Elasticsearch Service on Elastic Cloud. The Elasticsearch Service is available on AWS, GCP, and Azure. Try it out for free. This deployment must include an APM & Fleet node.
    • Kibana user with All privileges on Fleet and Integrations. Since many Integrations assets are shared across spaces, users need the Kibana privileges in all spaces.
  • An internet connection is required for Kibana to download integration packages from the Elastic Package Registry. Make sure the Kibana server can connect to https://epr.elastic.co on port 443. If your environment has network traffic restrictions, there are ways to work around this requirement. See Air-gapped environments for more information.
Step 1: Set up Fleet
edit

Use Fleet in Kibana to get logs, metrics, and security data into the Elastic Stack.

Not using Fleet? Advanced users who want to configure and manage Elastic Agents manually can run agents standalone.

The first time you use Fleet, you might need to set it up and add a Fleet Server:

Elastic Cloud runs a hosted version of Fleet Server. No extra setup is required unless you want to scale your deployment.

To confirm that Fleet Server is available in your deployment:

  1. Log in to Kibana and go to Management > Fleet.
  2. Click the Agents tab.
  3. Under Agent policy, look for Elastic Cloud agent policy — Fleet Server is the agent enrolled in the Elastic Cloud agent policy. This policy is managed by Elastic Cloud. You cannot modify it. Confirm that the agent status is Healthy.

Don’t see the Fleet Server agent? Make sure your deployment includes an APM & Fleet node. This node is required to use Fleet Server.

Fleet Server hosted agent

When using our hosted Elasticsearch Service, it’s recommended that you use our hosted version of Fleet Server. However, you can choose to deploy and self-manage Fleet Servers.

For more information, refer to Fleet Server.

Step 2: Add an Elastic Agent to Fleet
edit

Elastic Agent is a single, unified agent that you can deploy to hosts or containers to collect data and send it to the Elastic Stack. Behind the scenes, Elastic Agent runs the Beats shippers or Elastic Endpoint required for your configuration.

To send logs and metrics to the Elastic Stack:

  1. On the machine where you’ll run Elastic Agent, download and extract the installation package.

    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.1.3-darwin-x86_64.tar.gz
    tar xzvf elastic-agent-8.1.3-darwin-x86_64.tar.gz

    See the download page for other installation options.

  2. On the Agents tab in Fleet, click Add agent.
  3. Under Enroll in Fleet, follow the in-product installation steps (skip the download step if you’ve already done it).

    add agent

    See the download page for other installation options.

Notes:

  • Notice that you can create a new agent policy to get started quickly. Enter a name for the policy, then expand Advanced options to view other policy settings. Click Create policy. Fleet creates the new policy and generates an enrollment token.
  • On macOS, Linux (tar package), and Windows, run the install command to install Elastic Agent as a managed service, enroll it in Fleet, and start the service. The DEB and RPM packages include a service unit for Linux systems with systemd, so use the enroll command instead of install.

    You must run this command as the root user because some integrations require root privileges to collect sensitive data.

    cd elastic-agent-8.1.3-darwin-x86_64
    sudo ./elastic-agent install --url=<fleet_server_url> --enrollment-token=<enrollment_token>  

    fleet_server_url is the host and IP where Fleet Server is running, and enrollment_token is the enrollment token acquired from Fleet.

    If you see an "x509: certificate signed by unknown authority" error, you might be trying to enroll in a Fleet Server that uses self-signed certs. To fix this problem in a non-production environment, pass the --insecure flag. For more information, refer to the troubleshooting guide.

    Refer to Installation layout for the location of installed Elastic Agent files.

Because Elastic Agent is installed as an auto-starting service, it will restart automatically if the system is rebooted.

To confirm that Elastic Agent is installed and running, go to the Agents tab in Fleet. Notice that the Default policy is assigned to the agent.

Fleet showing enrolled agents

If the status hangs at Enrolling, make sure the elastic-agent process is running.

If you run into problems:

For information about managing Elastic Agent in Fleet, refer to Centrally manage Elastic Agents in Fleet.

Step 3: Monitor host logs and metrics
edit

Next, view the data sent by Elastic Agent. Right now, Elastic Agent is only sending data about the host system because you haven’t configured the agent to collect data from other sources yet.

To see host logs and metrics:

  1. In Fleet, click the Data streams tab.
  2. In the Actions column, navigate to the dashboards corresponding to the data stream. For example, to see host metrics, select one of the system datasets:

    Fleet showing data streams list

    Then navigate to the [Metrics System] Host overview dashboard:

    Host overview dashboard in Kibana
Step 4: Monitor services using real browsers and lightweight HTTP, TCP, and ICMP checks
edit

[beta] This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features. Next, you’ll add the Elastic Synthetics integration, enabling you to monitor the status and response times of applications and services in real time. You can monitor the availability of network endpoints via HTTP, TCP, ICMP or Browser monitors.

Add the Elastic Synthetics integration to the default policy used by your agent. You use policies to manage settings across a group of agents. An agent policy may contain any number of integrations for collecting observability data from the various services running on your host.

  1. In Kibana, select Add integrations, and search for the Elastic Synthetics integration.

    Fleet showing Synthetics integration
  2. Click the Elastic Synthetics integration to see more details about it, then click Add Elastic Synthetics.

    Fleet showing Synthetics integration overview
  3. On the Add Elastic Synthetics integration page, under Configure integration, enter the integration name and select your desired monitor type from the following monitor types:

    HTTP

    Connects via HTTP and verifies that the host returns the expected response.

    For detailed information about HTTP options, refer to our Heartbeat documentation.

    TCP

    Connects via TCP and verifies the endpoint by sending and receiving a custom payload. By default, the hostname and port are required.

    For detailed information about TCP options, refer to our Heartbeat documentation.

    ICMP

    Uses an ICMP v4 and v6 Echo Request to ping the configured hosts. By default, the host name is required.

    For detailed information about ICMP options, refer to our Heartbeat documentation.

    Browser

    Runs automated tests using a real Chromium browser via the synthetics agent.

    For detailed information about browser options, refer to our Heartbeat documentation.

    NOTE: To create a browser monitor, you must use the elastic-agent-complete Docker container as this contains the dependencies to run browser monitors. To learn more, refer to Set up monitors.

  4. Enter the URL you want to monitor for availability and select a monitor interval in seconds or minutes. By default, a monitoring schedule of every 3 minutes is selected.
  5. The HTTP and TCP monitor types both support TLS. Under TLS settings, select Enable TLS configuration. Click the down arrow next to advanced HTTP or TCP options, and then enter your required settings.
  6. Under Apply to agent policy, select the default policy.

    Fleet Add Synthetics integration page
  7. When you’re done, click Save and continue, then Save and deploy changes.
  8. To see the updated policy, click the Default policy link.

    The newly added Elastic Synthetics integration should appear under Integrations in the default policy, along with the System integration.

    Fleet showing default agent policy with synthetics-1 datasource

    All Elastic Agents that use this policy will collect logs, metrics, and uptime data from the host.

  9. To view the data in the Uptime app, go to Observability > Uptime.
Step 5: Monitor Nginx logs and metrics
edit

Next, you’ll browse a catalog of integrations, then add an Nginx integration to the default policy used by your agent.

For these steps, we assume that you have nginx running on some of your infrastructure, and want to collect logs and metrics from it.

  1. In Kibana, go back to Add integrations, and search for the Nginx integration.

    Fleet showing Nginx integration
  2. Click the Nginx integration to see more details about it, then click Add Nginx.

    Fleet showing Nginx integration overview
  3. On the Add Nginx integration page, select the default policy.

    Fleet Add Nginx integration page
  4. Under Configure integration, click the down arrow next to enabled streams and make sure the Paths are correct for your host. Inspect or change other settings
  5. When you’re done, save and deploy the changes.
  6. To see the updated policy, click the Default policy link.

    The newly added Nginx integration should appear under Integrations in the default policy, along with the System and Elastic Synthetics integrations.

    Fleet showing default agent policy with nginx-1 datasource

    All Elastic Agents that use this policy will collect logs and metrics from the Nginx server and the host, along with uptime data.

  7. To view the data, go to Management > Fleet, then click the Data streams tab.
  8. In the Actions column, navigate to the dashboards corresponding to the data stream.
What’s next?
edit
  • Now that data is streaming into the Elastic Stack, take your investigation to a deeper level! Use Elastic Observability to unify your logs, metrics, uptime, and application performance data.
  • Want to protect your endpoints from security threats? Try Elastic Security. Adding endpoint protection is just another integration that you add to the agent policy!
  • Are your eyes bleary from staring at a wall of screens? Create alerts and find out about problems while sipping your favorite beverage poolside.
  • Want Elastic to do the heavy lifting? Use machine learning to detect anomalies.
  • Got everything working like you want it? Roll out your agent policies to other hosts by deploying Elastic Agents across your infrastructure!