configuring-metricbeat.asciidoc 6.0 KB

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