[[configuring-elastic-agent]] == Collecting {es} monitoring data with {agent} [subs="attributes"] ++++ Collecting monitoring data with {agent} ++++ In 8.5 and later, you can use {agent} to collect data about {es} and ship it to the monitoring cluster, rather than <> or routing it through exporters as described in <>. [discrete] === Prerequisites * (Optional) Create a monitoring cluster as described in <>. * Create a user on the production cluster that has the `remote_monitoring_collector` {ref}/built-in-roles.html[built-in role]. [discrete] === Add {es} monitoring data To collect {es} monitoring data, add an {es} integration to an {agent} and deploy it to the host where {es} is running. . Go to the {kib} home page and click **Add integrations**. . In the query bar, search for and select the **{es}** integration for {agent}. . Read the overview to make sure you understand integration requirements and other considerations. . Click **Add Elasticsearch**. + TIP: If you're installing an integration for the first time, you may be prompted to install {agent}. Click **Add integration only (skip agent installation)**. . Configure the integration name and optionally add a description. Make sure you configure all required settings: .. Under **Collect Elasticsearch logs**, modify the log paths to match your {es} environment. .. Under **Collect Elasticsearch metrics**, make sure the hosts setting points to your {es} host URLs. By default, the integration collects {es} monitoring metrics from `localhost:9200`. If that host and port number are not correct, update the `hosts` setting. If you configured {es} to use encrypted communications, you must access it via HTTPS. For example, use a `hosts` setting like `https://localhost:9200`. .. Expand **Advanced options**. If the Elastic {security-features} are enabled, enter the username and password of a user that has the `remote_monitoring_collector` role. .. Specify the scope: ** Specify `cluster` if each entry in the hosts list indicates a single endpoint for a distinct {es} cluster (for example, a load-balancing proxy fronting the cluster that directs requests to the master-ineligible nodes in the cluster). ** Otherwise, accept the default scope, `node`. If this scope is set, you will need to install {agent} on each {es} node to collect all metrics. {agent} will collect most of the metrics from the elected master of the cluster, so you must scale up all your master-eligible nodes to account for this extra load. Do not use this `node` if you have dedicated master nodes. . Choose where to add the integration policy. Click **New hosts** to add it to new agent policy or **Existing hosts** to add it to an existing agent policy. . Click **Save and continue**. This step takes a minute or two to complete. When it's done, you'll have an agent policy that contains an integration for collecting monitoring data from {es}. . If an {agent} is already assigned to the policy and deployed to the host where {es} is running, you're done. Otherwise, you need to deploy an {agent}. To deploy an {agent}: .. Go to **{fleet} -> Agents**, then click **Add agent**. .. Follow the steps in the **Add agent** flyout to download, install, and enroll the {agent}. Make sure you choose the agent policy you created earlier. . Wait a minute or two until incoming data is confirmed. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].