configuring-metricbeat.asciidoc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. [role="xpack"]
  2. [[configuring-metricbeat]]
  3. == Collecting {es} monitoring data with {metricbeat}
  4. [subs="attributes"]
  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. . Enable the collection of monitoring data.
  13. +
  14. --
  15. // tag::enable-collection[]
  16. Set `xpack.monitoring.collection.enabled` to `true` on the
  17. production cluster. By default, it is disabled (`false`).
  18. You can use the following APIs to review and change this setting:
  19. [source,console]
  20. ----------------------------------
  21. GET _cluster/settings
  22. ----------------------------------
  23. [source,console]
  24. ----------------------------------
  25. PUT _cluster/settings
  26. {
  27. "persistent": {
  28. "xpack.monitoring.collection.enabled": true
  29. }
  30. }
  31. ----------------------------------
  32. // TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release.]
  33. If {es} {security-features} are enabled, you must have `monitor` cluster privileges to
  34. view the cluster settings and `manage` cluster privileges to change them.
  35. // end::enable-collection[]
  36. For more information, see <<monitoring-settings>> and <<cluster-update-settings>>.
  37. --
  38. . {metricbeat-ref}/metricbeat-installation-configuration.html[Install
  39. {metricbeat}]. Ideally install a single {metricbeat} instance configured with
  40. `scope: cluster` and configure `hosts` to point to an endpoint (e.g. a
  41. load-balancing proxy) which directs requests to the master-ineligible nodes in
  42. the cluster. If this is not possible then install one {metricbeat} instance for
  43. each {es} node in the production cluster and use the default `scope: node`.
  44. When {metricbeat} is monitoring {es} with `scope: node` then you must install a
  45. {metricbeat} instance for each {es} node. If you don't, some metrics will not
  46. be collected. {metricbeat} with `scope: node` collects most of the metrics from
  47. the elected master of the cluster, so you must scale up all your
  48. master-eligible nodes to account for this extra load and you should not use
  49. this mode if you have dedicated master nodes.
  50. . Enable the {es} module in {metricbeat} on each {es} node.
  51. +
  52. --
  53. For example, to enable the default configuration for the {stack-monitor-features}
  54. in the `modules.d` directory, run the following command:
  55. ["source","sh",subs="attributes,callouts"]
  56. ----------------------------------------------------------------------
  57. metricbeat modules enable elasticsearch-xpack
  58. ----------------------------------------------------------------------
  59. For more information, refer to
  60. {metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module].
  61. --
  62. . Configure the {es} module in {metricbeat} on each {es} node.
  63. +
  64. --
  65. The `modules.d/elasticsearch-xpack.yml` file contains the following settings:
  66. [source,yaml]
  67. ----------------------------------
  68. - module: elasticsearch
  69. xpack.enabled: true
  70. period: 10s
  71. hosts: ["http://localhost:9200"] <1>
  72. #scope: node <2>
  73. #username: "user"
  74. #password: "secret"
  75. #ssl.enabled: true
  76. #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
  77. #ssl.certificate: "/etc/pki/client/cert.pem"
  78. #ssl.key: "/etc/pki/client/cert.key"
  79. #ssl.verification_mode: "full"
  80. ----------------------------------
  81. <1> By default, the module collects {es} monitoring metrics from
  82. `http://localhost:9200`. If that host and port number are not correct, you must
  83. update the `hosts` setting. If you configured {es} to use encrypted
  84. communications, you must access it via HTTPS. For example, use a `hosts` setting
  85. like `https://localhost:9200`.
  86. <2> By default, `scope` is set to `node` and each entry in the `hosts` list
  87. indicates a distinct node in an {es} cluster. If you set `scope` to `cluster`
  88. then each entry in the `hosts` list indicates a single endpoint for a distinct
  89. {es} cluster (for example, a load-balancing proxy fronting the cluster). You
  90. should use `scope: cluster` if the cluster has dedicated master nodes, and
  91. configure the endpoint in the `hosts` list not to direct requests to the
  92. dedicated master nodes.
  93. If Elastic {security-features} are enabled, you must also provide a user ID
  94. and password so that {metricbeat} can collect metrics successfully:
  95. .. Create a user on the production cluster that has the
  96. <<built-in-roles,`remote_monitoring_collector` built-in role>>.
  97. Alternatively, use the
  98. <<built-in-users,`remote_monitoring_user` built-in user>>.
  99. .. Add the `username` and `password` settings to the {es} module configuration
  100. file.
  101. .. If TLS is enabled on the HTTP layer of your {es} cluster, you must either use https as the URL scheme in the `hosts` setting or add the `ssl.enabled: true` setting. Depending on the TLS configuration of your {es} cluster, you might also need to specify {metricbeat-ref}/configuration-ssl.html[additional ssl.*] settings.
  102. --
  103. . Optional: Disable the system module in {metricbeat}.
  104. +
  105. --
  106. By default, the {metricbeat-ref}/metricbeat-module-system.html[system module] is
  107. enabled. The information it collects, however, is not shown on the *Monitoring*
  108. page in {kib}. Unless you want to use that information for other purposes, run
  109. the following command:
  110. ["source","sh",subs="attributes,callouts"]
  111. ----------------------------------------------------------------------
  112. metricbeat modules disable system
  113. ----------------------------------------------------------------------
  114. --
  115. . Identify where to send the monitoring data.
  116. +
  117. --
  118. TIP: In production environments, we strongly recommend using a separate cluster
  119. (referred to as the _monitoring cluster_) to store the data. Using a separate
  120. monitoring cluster prevents production cluster outages from impacting your
  121. ability to access your monitoring data. It also prevents monitoring activities
  122. from impacting the performance of your production cluster.
  123. For example, specify the {es} output information in the {metricbeat}
  124. configuration file (`metricbeat.yml`):
  125. [source,yaml]
  126. ----------------------------------
  127. output.elasticsearch:
  128. # Array of hosts to connect to.
  129. hosts: ["http://es-mon-1:9200", "http://es-mon-2:9200"] <1>
  130. # Optional protocol and basic auth credentials.
  131. #protocol: "https"
  132. #username: "elastic"
  133. #password: "changeme"
  134. ----------------------------------
  135. <1> In this example, the data is stored on a monitoring cluster with nodes
  136. `es-mon-1` and `es-mon-2`.
  137. If you configured the monitoring cluster to use encrypted communications, you
  138. must access it via HTTPS. For example, use a `hosts` setting like
  139. `https://es-mon-1:9200`.
  140. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  141. cluster that stores the monitoring data must have at least one
  142. <<ingest,ingest node>>.
  143. If {es} {security-features} are enabled on the monitoring cluster, you must
  144. provide a valid user ID and password so that {metricbeat} can send metrics
  145. successfully:
  146. .. Create a user on the monitoring cluster that has the
  147. <<built-in-roles,`remote_monitoring_agent` built-in role>>.
  148. Alternatively, use the
  149. <<built-in-users,`remote_monitoring_user` built-in user>>.
  150. .. Add the `username` and `password` settings to the {es} output information in
  151. the {metricbeat} configuration file.
  152. For more information about these configuration options, see
  153. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  154. --
  155. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node.
  156. . Disable the default collection of {es} monitoring metrics.
  157. +
  158. --
  159. Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on the
  160. production cluster.
  161. You can use the following API to change this setting:
  162. [source,console]
  163. ----------------------------------
  164. PUT _cluster/settings
  165. {
  166. "persistent": {
  167. "xpack.monitoring.elasticsearch.collection.enabled": false
  168. }
  169. }
  170. ----------------------------------
  171. // TEST[warning:[xpack.monitoring.elasticsearch.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release.]
  172. If {es} {security-features} are enabled, you must have `monitor` cluster
  173. privileges to view the cluster settings and `manage` cluster privileges
  174. to change them.
  175. --
  176. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].