Collect Logstash monitoring data with Metricbeat
You can use Metricbeat to collect data about Logstash and ship it to the monitoring cluster. The benefit of Metricbeat collection is that the monitoring agent remains active even if the Logstash instance does not.
This step requires Elasticsearch with Metricbeat monitoring setup.
To collect and ship monitoring data:
- Disable default collection of monitoring metrics
- Specify the target cluster_uuid
- Install and configure Metricbeat to collect monitoring data
Want to use Elastic Agent instead? Refer to Collect monitoring data for stack monitoring.
Set the monitoring.enabled to false in logstash.yml to disable to default monitoring:
monitoring.enabled: false
		
	You will need to determine which Elasticsearch cluster that Logstash will bind metrics to in the Stack Monitoring UI by specifying the cluster_uuid. When pipelines contain Elasticsearch output plugins, the cluster_uuid is automatically calculated, and the metrics should be bound without any additional settings.
To override automatic values, or if your pipeline does not contain any Elasticsearch output plugins, you can bind the metrics of Logstash to a specific cluster, by defining the target cluster in the monitoring.cluster_uuid setting. in the configuration file (logstash.yml):
monitoring.cluster_uuid: PRODUCTION_ES_CLUSTER_UUID
		
	Refer to Elasticsearch cluster stats page to figure out how to get your cluster cluster_uuid.
- Install Metricbeat on the same server as Logstash. 
- Enable the - logstash-xpackmodule in Metricbeat.- To enable the default configuration in the Metricbeat - modules.ddirectory, run:- deb or rpm: - metricbeat modules enable logstash-xpack- linux or mac: - ./metricbeat modules enable logstash-xpack- win: - PS > .\metricbeat.exe modules enable logstash-xpack- For more information, see Specify which modules to run and beat module. 
- Configure the - logstash-xpackmodule in Metricbeat.- The - modules.d/logstash-xpack.ymlfile contains these settings:- - module: logstash metricsets: - node - node_stats period: 10s hosts: ["localhost:9600"] #username: "user" #password: "secret" xpack.enabled: trueTip- For the best experience with Stack Monitoring, we recommend collecting both - nodeand- node_statsmetricsets. Turning off either of these will result in incomplete or missing visualizations.- Set the - hosts,- username, and- passwordto authenticate with Logstash.- By default, the module collects Logstash monitoring data from - localhost:9600.- To monitor multiple Logstash instances, specify a list of hosts, for example: - hosts: ["http://localhost:9601","http://localhost:9602","http://localhost:9603"]- Elastic security. The Elastic security features are enabled by default. You must provide a user ID and password so that Metricbeat can collect metrics successfully: - Create a user on the production cluster that has the remote_monitoring_collectorbuilt-in role.
- Add the usernameandpasswordsettings to the module configuration file (logstash-xpack.yml).
 
- Create a user on the production 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://es-mon2:9200"] # Optional protocol and basic auth credentials. #protocol: "https" #username: "elastic" #password: "changeme"- In this example, the data is stored on a monitoring cluster with nodes es-mon-1andes-mon-2.
 - If you configured the monitoring cluster to use encrypted communications, you must access it via HTTPS. For example, use a - hostssetting like- https://es-mon-1:9200.Important- The Elasticsearch monitoring features use ingest pipelines, therefore the cluster that stores the monitoring data must have at least one ingest node. - Elastic security. The Elastic security features are enabled by default. You must provide a user ID and password so that Metricbeat can send metrics successfully: - Create a user on the monitoring cluster that has the - remote_monitoring_agentbuilt-in role. Alternatively, use the- remote_monitoring_userbuilt-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 - <<feature-roles>>.
- Add the - usernameand- passwordsettings to the Elasticsearch output information in the Metricbeat configuration file.
 - For more information about these configuration options, see Configure the Elasticsearch output. 
- In this example, the data is stored on a monitoring cluster with nodes 
- Start Metricbeat to begin collecting monitoring data. 
Your monitoring setup is complete.