configuring-metricbeat.asciidoc 6.7 KB

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