configuring-metricbeat.asciidoc 6.8 KB

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