configuring-metricbeat.asciidoc 7.9 KB

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