configuring-metricbeat.asciidoc 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 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 {metricbeat}] on each
  36. {es} node in the production cluster. Failure to install on each node may result in incomplete or missing results.
  37. . Enable the {es} module in {metricbeat} on each {es} node.
  38. +
  39. --
  40. For example, to enable the default configuration for the {stack-monitor-features}
  41. in the `modules.d` directory, run the following command:
  42. ["source","sh",subs="attributes,callouts"]
  43. ----------------------------------------------------------------------
  44. metricbeat modules enable elasticsearch-xpack
  45. ----------------------------------------------------------------------
  46. For more information, refer to
  47. {metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module].
  48. --
  49. . Configure the {es} module in {metricbeat} on each {es} node.
  50. +
  51. --
  52. The `modules.d/elasticsearch-xpack.yml` file contains the following settings:
  53. [source,yaml]
  54. ----------------------------------
  55. - module: elasticsearch
  56. xpack.enabled: true
  57. period: 10s
  58. hosts: ["http://localhost:9200"] <1>
  59. #scope: node <2>
  60. #username: "user"
  61. #password: "secret"
  62. #ssl.enabled: true
  63. #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
  64. #ssl.certificate: "/etc/pki/client/cert.pem"
  65. #ssl.key: "/etc/pki/client/cert.key"
  66. #ssl.verification_mode: "full"
  67. ----------------------------------
  68. <1> By default, the module collects {es} monitoring metrics from
  69. `http://localhost:9200`. If that host and port number are not correct, you must
  70. update the `hosts` setting. If you configured {es} to use encrypted
  71. communications, you must access it via HTTPS. For example, use a `hosts` setting
  72. like `https://localhost:9200`.
  73. <2> By default, `scope` is set to `node` and each entry in the `hosts` list
  74. indicates a distinct node in an {es} cluster. If you set `scope` to `cluster`,
  75. each entry in the `hosts` list indicates a single endpoint for a distinct {es}
  76. cluster (for example, a load-balancing proxy fronting the cluster).
  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. <<built-in-roles,`remote_monitoring_collector` built-in role>>.
  81. Alternatively, use the
  82. <<built-in-users,`remote_monitoring_user` built-in user>>.
  83. .. Add the `username` and `password` settings to the {es} module configuration
  84. file.
  85. .. 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.
  86. --
  87. . Optional: Disable the system module in {metricbeat}.
  88. +
  89. --
  90. By default, the {metricbeat-ref}/metricbeat-module-system.html[system module] is
  91. enabled. The information it collects, however, is not shown on the *Monitoring*
  92. page in {kib}. Unless you want to use that information for other purposes, run
  93. the following command:
  94. ["source","sh",subs="attributes,callouts"]
  95. ----------------------------------------------------------------------
  96. metricbeat modules disable system
  97. ----------------------------------------------------------------------
  98. --
  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. # Array of hosts to connect to.
  113. hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>
  114. # Optional protocol and basic auth credentials.
  115. #protocol: "https"
  116. #username: "elastic"
  117. #password: "changeme"
  118. ----------------------------------
  119. <1> In this example, the data is stored on a monitoring cluster with nodes
  120. `es-mon-1` and `es-mon-2`.
  121. If you configured the monitoring cluster to use encrypted communications, you
  122. must access it via HTTPS. For example, use a `hosts` setting like
  123. `https://es-mon-1:9200`.
  124. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  125. cluster that stores the monitoring data must have at least one
  126. <<ingest,ingest node>>.
  127. If {es} {security-features} are enabled on the monitoring cluster, you must
  128. provide a valid user ID and password so that {metricbeat} can send metrics
  129. successfully:
  130. .. Create a user on the monitoring cluster that has the
  131. <<built-in-roles,`remote_monitoring_agent` built-in role>>.
  132. Alternatively, use the
  133. <<built-in-users,`remote_monitoring_user` built-in user>>.
  134. .. Add the `username` and `password` settings to the {es} output information in
  135. the {metricbeat} configuration file.
  136. For more information about these configuration options, see
  137. {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output].
  138. --
  139. . {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node.
  140. . Disable the default collection of {es} monitoring metrics.
  141. +
  142. --
  143. Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on the
  144. production cluster.
  145. You can use the following API to change this setting:
  146. [source,console]
  147. ----------------------------------
  148. PUT _cluster/settings
  149. {
  150. "persistent": {
  151. "xpack.monitoring.elasticsearch.collection.enabled": false
  152. }
  153. }
  154. ----------------------------------
  155. If {es} {security-features} are enabled, you must have `monitor` cluster
  156. privileges to view the cluster settings and `manage` cluster privileges
  157. to change them.
  158. --
  159. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].