configuring-metricbeat.asciidoc 6.6 KB

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