configuring-metricbeat.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. To learn about monitoring in general, see
  14. {stack-ov}/xpack-monitoring.html[Monitoring the {stack}].
  15. //NOTE: The tagged regions are re-used in the Stack Overview.
  16. . Enable the collection of monitoring data. +
  17. +
  18. --
  19. // tag::enable-collection[]
  20. Set `xpack.monitoring.collection.enabled` to `true` on each node in the
  21. production cluster. By default, it is is disabled (`false`).
  22. NOTE: You can specify this setting in either the `elasticsearch.yml` on each
  23. node or across the cluster as a dynamic cluster setting. If {es}
  24. {security-features} are enabled, you must have `monitor` cluster privileges to
  25. view the cluster settings and `manage` cluster privileges to change them.
  26. For example, you can use the following APIs to review and change this setting:
  27. [source,js]
  28. ----------------------------------
  29. GET _cluster/settings
  30. PUT _cluster/settings
  31. {
  32. "persistent": {
  33. "xpack.monitoring.collection.enabled": true
  34. }
  35. }
  36. ----------------------------------
  37. // CONSOLE
  38. // end::enable-collection[]
  39. For more information, see <<monitoring-settings>> and <<cluster-update-settings>>.
  40. --
  41. . Disable the default collection of {es} monitoring metrics. +
  42. +
  43. --
  44. // tag::disable-default-collection[]
  45. Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on each node
  46. in the production cluster.
  47. NOTE: You can specify this setting in either the `elasticsearch.yml` on each
  48. node or across the cluster as a dynamic cluster setting. If {es}
  49. {security-features} are enabled, you must have `monitor` cluster privileges to
  50. view the cluster settings and `manage` cluster privileges to change them.
  51. For example, you can use the following API to change this setting:
  52. [source,js]
  53. ----------------------------------
  54. PUT _cluster/settings
  55. {
  56. "persistent": {
  57. "xpack.monitoring.elasticsearch.collection.enabled": false
  58. }
  59. }
  60. ----------------------------------
  61. // CONSOLE
  62. Leave `xpack.monitoring.enabled` set to its default value (`true`).
  63. // end::disable-default-collection[]
  64. --
  65. . {metricbeat-ref}/metricbeat-installation.html[Install {metricbeat}] on each
  66. {es} node in the production cluster.
  67. . Enable the {es} {xpack} module in {metricbeat} on each {es} node. +
  68. +
  69. --
  70. // tag::enable-es-module[]
  71. For example, to enable the default configuration in the `modules.d` directory,
  72. run the following command:
  73. ["source","sh",subs="attributes,callouts"]
  74. ----------------------------------------------------------------------
  75. metricbeat modules enable elasticsearch-xpack
  76. ----------------------------------------------------------------------
  77. For more information, see
  78. {metricbeat-ref}/configuration-metricbeat.html[Specify which modules to run] and
  79. {metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module].
  80. // end::enable-es-module[]
  81. --
  82. . Configure the {es} {xpack} module in {metricbeat} on each {es} node. +
  83. +
  84. --
  85. // tag::configure-es-module[]
  86. The `modules.d/elasticsearch-xpack.yml` file contains the following settings:
  87. [source,yaml]
  88. ----------------------------------
  89. - module: elasticsearch
  90. metricsets:
  91. - ccr
  92. - cluster_stats
  93. - index
  94. - index_recovery
  95. - index_summary
  96. - ml_job
  97. - node_stats
  98. - shard
  99. period: 10s
  100. hosts: ["http://localhost:9200"]
  101. #username: "user"
  102. #password: "secret"
  103. xpack.enabled: true
  104. ----------------------------------
  105. By default, the module collects {es} monitoring metrics from
  106. `http://localhost:9200`. If that host and port number are not correct, you must
  107. update the `hosts` setting. If you configured {es} to use encrypted
  108. communications, you must access it via HTTPS. For example, use a `hosts` setting
  109. like `https://localhost:9200`.
  110. // end::configure-es-module[]
  111. // tag::remote-monitoring-user[]
  112. If Elastic {security-features} are enabled, you must also provide a user ID
  113. and password so that {metricbeat} can collect metrics successfully:
  114. .. Create a user on the production cluster that has the
  115. {stack-ov}/built-in-roles.html[`remote_monitoring_collector` built-in role].
  116. Alternatively, use the
  117. {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  118. .. Add the `username` and `password` settings to the {es} module configuration
  119. file.
  120. // end::remote-monitoring-user[]
  121. --
  122. . Optional: Disable the system module in {metricbeat}.
  123. +
  124. --
  125. // tag::disable-system-module[]
  126. By default, the {metricbeat-ref}/metricbeat-module-system.html[system module] is
  127. enabled. The information it collects, however, is not shown on the *Monitoring*
  128. page in {kib}. Unless you want to use that information for other purposes, run
  129. the following command:
  130. ["source","sh",subs="attributes,callouts"]
  131. ----------------------------------------------------------------------
  132. metricbeat modules disable system
  133. ----------------------------------------------------------------------
  134. // end::disable-system-module[]
  135. --
  136. . Identify where to send the monitoring data. +
  137. +
  138. --
  139. TIP: In production environments, we strongly recommend using a separate cluster
  140. (referred to as the _monitoring cluster_) to store the data. Using a separate
  141. monitoring cluster prevents production cluster outages from impacting your
  142. ability to access your monitoring data. It also prevents monitoring activities
  143. from impacting the performance of your production cluster.
  144. For example, specify the {es} output information in the {metricbeat}
  145. configuration file (`metricbeat.yml`):
  146. [source,yaml]
  147. ----------------------------------
  148. output.elasticsearch:
  149. # Array of hosts to connect to.
  150. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>
  151. # Optional protocol and basic auth credentials.
  152. #protocol: "https"
  153. #username: "elastic"
  154. #password: "changeme"
  155. ----------------------------------
  156. <1> In this example, the data is stored on a monitoring cluster with nodes
  157. `es-mon-1` and `es-mon-2`.
  158. If you configured the monitoring cluster to use encrypted communications, you
  159. must access it via HTTPS. For example, use a `hosts` setting like
  160. `https://es-mon-1:9200`.
  161. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  162. cluster that stores the monitoring data must have at least one
  163. <<ingest,ingest node>>.
  164. If {es} {security-features} are enabled on the monitoring cluster, you must
  165. provide a valid user ID and password so that {metricbeat} can send metrics
  166. successfully:
  167. .. Create a user on the monitoring cluster that has the
  168. {stack-ov}/built-in-roles.html[`remote_monitoring_agent` built-in role].
  169. Alternatively, use the
  170. {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  171. .. Add the `username` and `password` settings to the {es} output information in
  172. the {metricbeat} configuration file.
  173. For more information about these configuration options, see
  174. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  175. --
  176. . <<starting-elasticsearch,Start {es}>> on each node.
  177. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node.
  178. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].