configuring-metricbeat.asciidoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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-xpack
  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. .. By default the module will collect {es} monitoring metrics from `http://localhost:9200`.
  75. If the local {es} node has a different address, you must specify it via the `hosts` setting
  76. in the `modules.d/elasticsearch-xpack.yml` file.
  77. .. If Elastic {security-features} are enabled, you must also provide a user ID
  78. and password so that {metricbeat} can collect metrics successfully.
  79. ... Create a user on the production cluster that has the
  80. {stack-ov}/built-in-roles.html[`remote_monitoring_collector` built-in role].
  81. Alternatively, use the {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  82. ... Add the `username` and `password` settings to the {es} module configuration
  83. file.
  84. +
  85. --
  86. For example, add the following settings in the `modules.d/elasticsearch-xpack.yml` file:
  87. [source,yaml]
  88. ----------------------------------
  89. - module: elasticsearch
  90. ...
  91. username: remote_monitoring_user
  92. password: YOUR_PASSWORD
  93. ----------------------------------
  94. --
  95. .. If you configured {es} to use <<configuring-tls,encrypted communications>>,
  96. you must access it via HTTPS. For example, use a `hosts` setting like
  97. `https://localhost:9200` in the `modules.d/elasticsearch-xpack.yml` file.
  98. .. Identify where to send the monitoring data. +
  99. +
  100. --
  101. TIP: In production environments, we strongly recommend using a separate cluster
  102. (referred to as the _monitoring cluster_) to store the data. Using a separate
  103. monitoring cluster prevents production cluster outages from impacting your
  104. ability to access your monitoring data. It also prevents monitoring activities
  105. from impacting the performance of your production cluster.
  106. For example, specify the {es} output information in the {metricbeat}
  107. configuration file (`metricbeat.yml`):
  108. [source,yaml]
  109. ----------------------------------
  110. output.elasticsearch:
  111. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>
  112. ----------------------------------
  113. <1> In this example, the data is stored on a monitoring cluster with nodes
  114. `es-mon-1` and `es-mon-2`.
  115. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  116. cluster that stores the monitoring data must have at least one
  117. <<ingest,ingest node>>.
  118. For more information about these configuration options, see
  119. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  120. --
  121. .. If {es} {security-features} are enabled on the monitoring cluster, you
  122. must provide a valid user ID and password so that {metricbeat} can send metrics
  123. successfully.
  124. ... Create a user on the monitoring cluster that has the
  125. {stack-ov}/built-in-roles.html[`remote_monitoring_agent` built-in role].
  126. Alternatively, use the
  127. {stack-ov}/built-in-users.html[`remote_monitoring_user` built-in user].
  128. ... Add the `username` and `password` settings to the {es} output information in
  129. the {metricbeat} configuration file (`metricbeat.yml`):
  130. +
  131. --
  132. [source,yaml]
  133. ----------------------------------
  134. output.elasticsearch:
  135. ...
  136. username: remote_monitoring_user
  137. password: YOUR_PASSWORD
  138. ----------------------------------
  139. --
  140. .. If you configured the monitoring cluster to use
  141. <<configuring-tls,encrypted communications>>, you must access it via
  142. HTTPS. For example, use a `hosts` setting like `https://es-mon-1:9200` in the
  143. `metricbeat.yml` file.
  144. . <<starting-elasticsearch,Start {es}>>.
  145. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}].
  146. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].