configuring-metricbeat.asciidoc 6.3 KB

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