configuring-metricbeat.asciidoc 6.0 KB

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