configuring-metricbeat.asciidoc 6.9 KB

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