Use Metricbeat to send monitoring data
In 7.3 and later, you can use Metricbeat to collect data about APM Server and ship it to the monitoring cluster. The benefit of using Metricbeat instead of internal collection is that the monitoring agent remains active even if the APM Server instance dies.
To collect and ship monitoring data:
- Configure the shipper you want to monitor
- Install and configure Metricbeat to collect monitoring data
Configure the shipper you want to monitor ¶
- Enable the HTTP endpoint to allow external collection of monitoring data: Add the following setting in the APM Server configuration file (
apm-server.yml
):http.enabled: true
http.port
to expose metrics for each shipper on a different port number:http.port: 5067
- Disable the default collection of APM Server monitoring metrics.
Add the following setting in the APM Server configuration file (apm-server.yml
):monitoring.enabled: false
- Configure host (optional).
If you intend to get metrics using Metricbeat installed on another server, you need to bind the APM Server to host’s IP:http.host: xxx.xxx.xxx.xxx
- Configure cluster UUID (optional).
To see the Beats monitoring section in Kibana if you have a cluster, you need to associate the APM Server with cluster UUID:monitoring.cluster_uuid: "cluster-uuid"
- Start APM Server.
Install and configure Metricbeat to collect monitoring data ¶
- Install Metricbeat on the same server as APM Server. To learn how, see Get started with Metricbeat. If you already have Metricbeat installed on the server, skip this step.
- Enable the
beat-xpack
module in Metricbeat.
For example, to enable the default configuration in themodules.d
directory, run the following command, using the correct command syntax for your OS:metricbeat modules enable beat-xpack
- Configure the
beat-xpack
module in Metricbeat.
Themodules.d/beat-xpack.yml
file contains the following settings:- module: beat metricsets: - stats - state period: 10s hosts: ["http://localhost:5066"] #username: "user" #password: "secret" xpack.enabled: true
hosts
,username
, andpassword
settings as required by your environment. For other module settings, it’s recommended that you accept the defaults. By default, the module collects APM Server monitoring data fromlocalhost:5066
. If you exposed the metrics on a different host or port when you enabled the HTTP endpoint, update thehosts
setting. To monitor multiple APM Server instances, specify a list of hosts, for example:hosts: ["http://localhost:5066","http://localhost:5067","http://localhost:5068"]
hosts
setting likehttps://localhost:5066
. If the Elastic security features are enabled, you must also provide a user ID 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
- 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.
::::{tip}
In production environments, we strongly recommend using a separate cluster (referred to as the monitoring cluster) to store the data. Using a separate monitoring cluster prevents production cluster outages from impacting your ability to access your monitoring data. It also prevents monitoring activities from impacting the performance of your production cluster.
:::: 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:1 # Optional protocol and basic auth credentials. #protocol: "https" 2 #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
.
hosts
setting likehttps://es-mon-1:9200
. ::::{important}
The Elasticsearch {monitor-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. ::::{tip}
If you’re using index lifecycle management, the remote monitoring user requires additional privileges to create and read indices. For more information, see Use feature roles.
:::: - Add the
username
andpassword
settings to the Elasticsearch output information in the Metricbeat configuration file.
- In this example, the data is stored on a monitoring cluster with nodes
- Start Metricbeat to begin collecting monitoring data.
- View the monitoring data in Kibana.