configuring-metricbeat.asciidoc 6.5 KB

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