configuring-metricbeat.asciidoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. [role="xpack"]
  2. [testenv="gold"]
  3. [[configuring-metricbeat]]
  4. === Collecting {es} monitoring data with {metricbeat}
  5. ++++
  6. <titleabbrev>Collecting monitoring data with {metricbeat}</titleabbrev>
  7. ++++
  8. beta[]
  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. . Enable the collection of monitoring data. Set
  16. `xpack.monitoring.collection.enabled` to `true` on each node in the production
  17. cluster. By default, it is is disabled (`false`).
  18. +
  19. --
  20. NOTE: You can specify this setting in either the `elasticsearch.yml` on each
  21. node or across the cluster as a dynamic cluster setting. If {es}
  22. {security-features} are enabled, you must have `monitor` cluster privileges to
  23. view the cluster settings and `manage` cluster privileges to change them.
  24. For example, you can use the following APIs to review and change this setting:
  25. [source,js]
  26. ----------------------------------
  27. GET _cluster/settings
  28. PUT _cluster/settings
  29. {
  30. "persistent": {
  31. "xpack.monitoring.collection.enabled": true
  32. }
  33. }
  34. ----------------------------------
  35. // CONSOLE
  36. For more information, see <<monitoring-settings>> and <<cluster-update-settings>>.
  37. --
  38. . Disable the default collection of {es} monitoring metrics. Set
  39. `xpack.monitoring.elasticsearch.collection.enabled` to `false` on each node in
  40. the production cluster.
  41. +
  42. --
  43. NOTE: You can specify this setting in either the `elasticsearch.yml` on each
  44. node or across the cluster as a dynamic cluster setting. If {es}
  45. {security-features} are enabled, you must have `monitor` cluster privileges to
  46. view the cluster settings and `manage` cluster privileges to change them.
  47. For example, you can use the following API to change this setting:
  48. [source,js]
  49. ----------------------------------
  50. PUT _cluster/settings
  51. {
  52. "persistent": {
  53. "xpack.monitoring.elasticsearch.collection.enabled": false
  54. }
  55. }
  56. ----------------------------------
  57. // CONSOLE
  58. Leave `xpack.monitoring.enabled` set to its default value (`true`).
  59. --
  60. . On each {es} node in the production cluster:
  61. .. {metricbeat-ref}/metricbeat-installation.html[Install {metricbeat}].
  62. .. Enable the {es} module in {metricbeat}. +
  63. +
  64. --
  65. For example, to enable the default configuration in the `modules.d` directory,
  66. run the following command:
  67. ["source","sh",subs="attributes,callouts"]
  68. ----------------------------------------------------------------------
  69. metricbeat modules enable elasticsearch
  70. ----------------------------------------------------------------------
  71. For more information, see
  72. {metricbeat-ref}/configuration-metricbeat.html[Specify which modules to run] and
  73. {metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module].
  74. --
  75. .. Configure the {es} module in {metricbeat}. +
  76. +
  77. --
  78. You must specify the following settings in the `modules.d/elasticsearch.yml` file:
  79. [source,yaml]
  80. ----------------------------------
  81. - module: elasticsearch
  82. metricsets:
  83. - ccr
  84. - cluster_stats
  85. - index
  86. - index_recovery
  87. - index_summary
  88. - ml_job
  89. - node_stats
  90. - shard
  91. period: 10s
  92. hosts: ["http://localhost:9200"] <1>
  93. xpack.enabled: true <2>
  94. ----------------------------------
  95. <1> This setting identifies the host and port number that are used to access {es}.
  96. <2> This setting ensures that {kib} can read this monitoring data successfully.
  97. That is to say, it's stored in the same location and format as monitoring data
  98. that is sent by <<es-monitoring-exporters,exporters>>.
  99. --
  100. .. If Elastic {security-features} are enabled, you must also provide a user ID
  101. and password so that {metricbeat} can collect metrics successfully.
  102. ... Create a user on the production cluster that has the
  103. {stack-ov}/built-in-roles.html[`remote_monitoring_collector` built-in role].
  104. Alternatively, use the {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  105. ... Add the `username` and `password` settings to the {es} module configuration
  106. file.
  107. +
  108. --
  109. For example, add the following settings in the `modules.d/elasticsearch.yml` file:
  110. [source,yaml]
  111. ----------------------------------
  112. - module: elasticsearch
  113. ...
  114. username: remote_monitoring_user
  115. password: YOUR_PASSWORD
  116. ----------------------------------
  117. --
  118. .. If you configured {es} to use <<configuring-tls,encrypted communications>>,
  119. you must access it via HTTPS. For example, use a `hosts` setting like
  120. `https://localhost:9200` in the `modules.d/elasticsearch.yml` file.
  121. .. Identify where to send the monitoring data. +
  122. +
  123. --
  124. TIP: In production environments, we strongly recommend using a separate cluster
  125. (referred to as the _monitoring cluster_) to store the data. Using a separate
  126. monitoring cluster prevents production cluster outages from impacting your
  127. ability to access your monitoring data. It also prevents monitoring activities
  128. from impacting the performance of your production cluster.
  129. For example, specify the {es} output information in the {metricbeat}
  130. configuration file (`metricbeat.yml`):
  131. [source,yaml]
  132. ----------------------------------
  133. output.elasticsearch:
  134. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>
  135. ----------------------------------
  136. <1> In this example, the data is stored on a monitoring cluster with nodes
  137. `es-mon-1` and `es-mon-2`.
  138. For more information about these configuration options, see
  139. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  140. --
  141. .. If {es} {security-features} are enabled on the monitoring cluster, you
  142. must provide a valid user ID and password so that {metricbeat} can send metrics
  143. successfully.
  144. ... Create a user on the monitoring cluster that has the
  145. {stack-ov}/built-in-roles.html[`remote_monitoring_agent` built-in role].
  146. Alternatively, use the
  147. {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  148. ... Add the `username` and `password` settings to the {es} output information in
  149. the {metricbeat} configuration file (`metricbeat.yml`):
  150. +
  151. --
  152. [source,yaml]
  153. ----------------------------------
  154. output.elasticsearch:
  155. ...
  156. username: remote_monitoring_user
  157. password: YOUR_PASSWORD
  158. ----------------------------------
  159. --
  160. .. If you configured the monitoring cluster to use
  161. <<configuring-tls,encrypted communications>>, you must access it via
  162. HTTPS. For example, use a `hosts` setting like `https://es-mon-1:9200` in the
  163. `metricbeat.yml` file.
  164. . <<starting-elasticsearch,Start {es}>>.
  165. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}].
  166. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].