configuring-metricbeat.asciidoc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. [role="xpack"]
  2. [testenv="gold"]
  3. [[configuring-metricbeat]]
  4. == Collecting {es} monitoring data with {metricbeat}
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Collecting monitoring data with {metricbeat}</titleabbrev>
  8. ++++
  9. In 6.5 and later, you can use {metricbeat} to collect data about {es}
  10. and ship it to the monitoring cluster, rather than routing it through exporters
  11. as described in <<collecting-monitoring-data>>.
  12. image::monitoring/images/metricbeat.png[Example monitoring architecture]
  13. . Enable the collection of monitoring data.
  14. +
  15. --
  16. // tag::enable-collection[]
  17. Set `xpack.monitoring.collection.enabled` to `true` on the
  18. production cluster. By default, it is is disabled (`false`).
  19. You can use the following APIs to review and change this setting:
  20. [source,console]
  21. ----------------------------------
  22. GET _cluster/settings
  23. PUT _cluster/settings
  24. {
  25. "persistent": {
  26. "xpack.monitoring.collection.enabled": true
  27. }
  28. }
  29. ----------------------------------
  30. If {es} {security-features} are enabled, you must have `monitor` cluster privileges to
  31. view the cluster settings and `manage` cluster privileges to change them.
  32. // end::enable-collection[]
  33. For more information, see <<monitoring-settings>> and <<cluster-update-settings>>.
  34. --
  35. . {metricbeat-ref}/metricbeat-installation-configuration.html[Install {metricbeat}] on each
  36. {es} node in the production cluster. Failure to install on each node may result in incomplete or missing results.
  37. . Enable the {es} {xpack} module in {metricbeat} on each {es} node.
  38. +
  39. --
  40. For example, to enable the default configuration in the `modules.d` directory,
  41. run the following command:
  42. ["source","sh",subs="attributes,callouts"]
  43. ----------------------------------------------------------------------
  44. metricbeat modules enable elasticsearch-xpack
  45. ----------------------------------------------------------------------
  46. Alternatively, you can use the {es} module, as described in the
  47. {metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module usage for {stack} monitoring].
  48. --
  49. . Configure the {es} {xpack} module in {metricbeat} on each {es} node.
  50. +
  51. --
  52. The `modules.d/elasticsearch-xpack.yml` file contains the following settings:
  53. [source,yaml]
  54. ----------------------------------
  55. - module: elasticsearch
  56. xpack.enabled: true
  57. period: 10s
  58. hosts: ["http://localhost:9200"] <1>
  59. #scope: node <2>
  60. #username: "user"
  61. #password: "secret"
  62. #ssl.enabled: true
  63. #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
  64. #ssl.certificate: "/etc/pki/client/cert.pem"
  65. #ssl.key: "/etc/pki/client/cert.key"
  66. #ssl.verification_mode: "full"
  67. xpack.enabled: true
  68. ----------------------------------
  69. <1> By default, the module collects {es} monitoring metrics from
  70. `http://localhost:9200`. If that host and port number are not correct, you must
  71. update the `hosts` setting. If you configured {es} to use encrypted
  72. communications, you must access it via HTTPS. For example, use a `hosts` setting
  73. like `https://localhost:9200`.
  74. <2> By default, `scope` is set to `node` and each entry in the `hosts` list
  75. indicates a distinct node in an {es} cluster. If you set `scope` to `cluster`,
  76. each entry in the `hosts` list indicates a single endpoint for a distinct {es}
  77. cluster (for example, a load-balancing proxy fronting the cluster).
  78. If Elastic {security-features} are enabled, you must also provide a user ID
  79. and password so that {metricbeat} can collect metrics successfully:
  80. .. Create a user on the production cluster that has the
  81. <<built-in-roles,`remote_monitoring_collector` built-in role>>.
  82. Alternatively, use the
  83. <<built-in-users,`remote_monitoring_user` built-in user>>.
  84. .. Add the `username` and `password` settings to the {es} module configuration
  85. file.
  86. .. If TLS is enabled on the HTTP layer of your {es} cluster, you must either use https as the URL scheme in the `hosts` setting or add the `ssl.enabled: true` setting. Depending on the TLS configuration of your {es} cluster, you might also need to specify {metricbeat-ref}/configuration-ssl.html[additional ssl.*] settings.
  87. --
  88. . Optional: Disable the system module in {metricbeat}.
  89. +
  90. --
  91. By default, the {metricbeat-ref}/metricbeat-module-system.html[system module] is
  92. enabled. The information it collects, however, is not shown on the *Monitoring*
  93. page in {kib}. Unless you want to use that information for other purposes, run
  94. the following command:
  95. ["source","sh",subs="attributes,callouts"]
  96. ----------------------------------------------------------------------
  97. metricbeat modules disable system
  98. ----------------------------------------------------------------------
  99. --
  100. . Identify where to send the monitoring data.
  101. +
  102. --
  103. TIP: In production environments, we strongly recommend using a separate cluster
  104. (referred to as the _monitoring cluster_) to store the data. Using a separate
  105. monitoring cluster prevents production cluster outages from impacting your
  106. ability to access your monitoring data. It also prevents monitoring activities
  107. from impacting the performance of your production cluster.
  108. For example, specify the {es} output information in the {metricbeat}
  109. configuration file (`metricbeat.yml`):
  110. [source,yaml]
  111. ----------------------------------
  112. output.elasticsearch:
  113. # Array of hosts to connect to.
  114. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>
  115. # Optional protocol and basic auth credentials.
  116. #protocol: "https"
  117. #username: "elastic"
  118. #password: "changeme"
  119. ----------------------------------
  120. <1> In this example, the data is stored on a monitoring cluster with nodes
  121. `es-mon-1` and `es-mon-2`.
  122. If you configured the monitoring cluster to use encrypted communications, you
  123. must access it via HTTPS. For example, use a `hosts` setting like
  124. `https://es-mon-1:9200`.
  125. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  126. cluster that stores the monitoring data must have at least one
  127. <<ingest,ingest node>>.
  128. If {es} {security-features} are enabled on the monitoring cluster, you must
  129. provide a valid user ID and password so that {metricbeat} can send metrics
  130. successfully:
  131. .. Create a user on the monitoring cluster that has the
  132. <<built-in-roles,`remote_monitoring_agent` built-in role>>.
  133. Alternatively, use the
  134. <<built-in-users,`remote_monitoring_user` built-in user>>.
  135. .. Add the `username` and `password` settings to the {es} output information in
  136. the {metricbeat} configuration file.
  137. For more information about these configuration options, see
  138. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  139. --
  140. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node.
  141. . Disable the default collection of {es} monitoring metrics.
  142. +
  143. --
  144. Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on the
  145. production cluster.
  146. You can use the following API to change this setting:
  147. [source,console]
  148. ----------------------------------
  149. PUT _cluster/settings
  150. {
  151. "persistent": {
  152. "xpack.monitoring.elasticsearch.collection.enabled": false
  153. }
  154. }
  155. ----------------------------------
  156. If {es} {security-features} are enabled, you must have `monitor` cluster
  157. privileges to view the cluster settings and `manage` cluster privileges
  158. to change them.
  159. --
  160. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].