configuring-metricbeat.asciidoc 6.7 KB

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