Monitor a Fleet-managed APM Server
editMonitor a Fleet-managed APM Server
editThis guide assumes you are already ingesting APM data into the Elastic Stack.
In 8.0 and later, you can use Metricbeat to collect data about APM Server and ship it to a monitoring cluster. To collect and ship monitoring data:
Configure Elastic Agent to send monitoring data
edit-
Enable monitoring of Elastic Agent by adding the following settings to your
elastic-agent.yml
configuration file: -
Enroll Elastic Agent
After editing
elastic-agent.yml
, you must re-enroll Elastic Agent for the changes to take effect.To enroll the Elastic Agent in Fleet:
elastic-agent enroll --url <string> --enrollment-token <string> [--ca-sha256 <string>] [--certificate-authorities <string>] [--daemon-timeout <duration>] [--delay-enroll] [--elastic-agent-cert <string>] [--elastic-agent-cert-key <string>] [--elastic-agent-cert-key-passphrase <string>] [--force] [--header <strings>] [--help] [--insecure ] [--proxy-disabled] [--proxy-header <strings>] [--proxy-url <string>] [--staging <string>] [--tag <string>] [global-flags]
See the Elastic Agent command reference for more information on the enroll command.
Install and configure Metricbeat to collect monitoring data
edit- Install Metricbeat on the same server as Elastic Agent. To learn how, see Get started with Metricbeat. If you already have Metricbeat installed, skip this step.
-
Enable the
beat-xpack
module in Metricbeat.For example, to enable the default configuration in the
modules.d
directory, run the following command, using the correct command syntax for your OS:metricbeat modules enable beat-xpack
For more information, see Configure modules and beat module.
-
Configure the
beat-xpack
module in Metricbeat.When complete, your
modules.d/beat-xpack.yml
file should look similar to this:- module: beat xpack.enabled: true period: 10s hosts: ["http://localhost:6791"] basepath: "/processes/apm-server-default" username: remote_monitoring_user password: your_password
-
Do not change the
module
name orxpack.enabled
boolean; these are required for stack monitoring. We recommend accepting the defaultperiod
for now. -
Set the
hosts
to match the host:port configured in yourelastic-agent.yml
file. In this example, that’shttp://localhost:6791
.To monitor multiple APM Server instances running in multiple Elastic Agents, specify a list of hosts, for example:
hosts: ["http://localhost:5066","http://localhost:5067","http://localhost:5068"]
If you configured Elastic Agent to use encrypted communications, you must access it via HTTPS. For example, use a
hosts
setting likehttps://localhost:5066
. -
APM Server metrics are exposed at
/processes/apm-server-default
. Add this location as thebasepath
. -
Set the
username
andpassword
settings as required by your environment. If Elastic security features are enabled, you must provide a username and password so that Metricbeat can collect metrics successfully:-
Create a user on the Elasticsearch cluster that has the
remote_monitoring_collector
built-in role. Alternatively, if it’s available in your environment, use theremote_monitoring_user
built-in user. -
Add the
username
andpassword
settings to the beat module configuration file.
-
Create a user on the Elasticsearch cluster that has the
-
Do not change the
-
Optional: Disable the system module in the Metricbeat.
By default, the system module is enabled. The information it collects, however, is not shown on the Stack Monitoring page in Kibana. Unless you want to use that information for other purposes, run the following command:
metricbeat modules disable system
-
Identify where to send the monitoring data.
In production environments, you should send your deployment logs and metrics to a dedicated monitoring deployment (referred to as the monitoring cluster). Monitoring indexes logs and metrics into Elasticsearch and these indexes consume storage, memory, and CPU cycles like any other index. By using a separate monitoring deployment, you avoid affecting your other production deployments and can view the logs and metrics even when a production deployment is unavailable.
For example, specify the Elasticsearch output information in the Metricbeat configuration file (
metricbeat.yml
):output.elasticsearch: # Array of hosts to connect to. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] # Optional protocol and basic auth credentials. #protocol: "https" #api_key: "id:api_key" #username: "elastic" #password: "changeme"
In this example, the data is stored on a monitoring cluster with nodes
es-mon-1
andes-mon-2
.Specify one of
api_key
orusername
/password
.If you configured the monitoring cluster to use encrypted communications, you must access it via HTTPS. For example, use a
hosts
setting likehttps://es-mon-1:9200
.The Elasticsearch monitoring features use ingest pipelines, therefore the cluster that stores the monitoring data must have at least one ingest node.
If the Elasticsearch security features are enabled on the monitoring cluster, you must provide a valid user ID and password so that Metricbeat can send metrics successfully:
-
Create a user on the monitoring cluster that has the
remote_monitoring_agent
built-in role. Alternatively, if it’s available in your environment, use theremote_monitoring_user
built-in user. -
Add the
username
andpassword
settings to the Elasticsearch output information in the Metricbeat configuration file.
For more information about these configuration options, see Configure the Elasticsearch output.
-
Create a user on the monitoring cluster that has the
- Start Metricbeat to begin collecting APM monitoring data.
- View the monitoring data in Kibana.