configuring-metricbeat.asciidoc 6.9 KB

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