collectors.asciidoc 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[es-monitoring-collectors]]
  4. == Collectors
  5. [IMPORTANT]
  6. =========================
  7. {metricbeat} is the recommended method for collecting and shipping monitoring
  8. data to a monitoring cluster.
  9. If you have previously configured legacy collection methods, you should migrate
  10. to using {metricbeat} collection methods. Use either {metricbeat} collection or
  11. legacy collection methods; do not use both.
  12. Learn more about <<configuring-metricbeat>>.
  13. =========================
  14. Collectors, as their name implies, collect things. Each collector runs once for
  15. each collection interval to obtain data from the public APIs in {es} and {xpack}
  16. that it chooses to monitor. When the data collection is finished, the data is
  17. handed in bulk to the <<es-monitoring-exporters,exporters>> to be sent to the
  18. monitoring clusters. Regardless of the number of exporters, each collector only
  19. runs once per collection interval.
  20. There is only one collector per data type gathered. In other words, for any
  21. monitoring document that is created, it comes from a single collector rather
  22. than being merged from multiple collectors. The {es} {monitor-features}
  23. currently have a few collectors because the goal is to minimize overlap between
  24. them for optimal performance.
  25. Each collector can create zero or more monitoring documents. For example,
  26. the `index_stats` collector collects all index statistics at the same time to
  27. avoid many unnecessary calls.
  28. [options="header"]
  29. |=======================
  30. | Collector | Data Types | Description
  31. | Cluster Stats | `cluster_stats`
  32. | Gathers details about the cluster state, including parts of the actual cluster
  33. state (for example `GET /_cluster/state`) and statistics about it (for example,
  34. `GET /_cluster/stats`). This produces a single document type. In versions prior
  35. to X-Pack 5.5, this was actually three separate collectors that resulted in
  36. three separate types: `cluster_stats`, `cluster_state`, and `cluster_info`. In
  37. 5.5 and later, all three are combined into `cluster_stats`. This only runs on
  38. the _elected_ master node and the data collected (`cluster_stats`) largely
  39. controls the UI. When this data is not present, it indicates either a
  40. misconfiguration on the elected master node, timeouts related to the collection
  41. of the data, or issues with storing the data. Only a single document is produced
  42. per collection.
  43. | Index Stats | `indices_stats`, `index_stats`
  44. | Gathers details about the indices in the cluster, both in summary and
  45. individually. This creates many documents that represent parts of the index
  46. statistics output (for example, `GET /_stats`). This information only needs to
  47. be collected once, so it is collected on the _elected_ master node. The most
  48. common failure for this collector relates to an extreme number of indices -- and
  49. therefore time to gather them -- resulting in timeouts. One summary
  50. `indices_stats` document is produced per collection and one `index_stats`
  51. document is produced per index, per collection.
  52. | Index Recovery | `index_recovery`
  53. | Gathers details about index recovery in the cluster. Index recovery represents
  54. the assignment of _shards_ at the cluster level. If an index is not recovered,
  55. it is not usable. This also corresponds to shard restoration via snapshots. This
  56. information only needs to be collected once, so it is collected on the _elected_
  57. master node. The most common failure for this collector relates to an extreme
  58. number of shards -- and therefore time to gather them -- resulting in timeouts.
  59. This creates a single document that contains all recoveries by default, which
  60. can be quite large, but it gives the most accurate picture of recovery in the
  61. production cluster.
  62. | Shards | `shards`
  63. | Gathers details about all _allocated_ shards for all indices, particularly
  64. including what node the shard is allocated to. This information only needs to be
  65. collected once, so it is collected on the _elected_ master node. The collector
  66. uses the local cluster state to get the routing table without any network
  67. timeout issues unlike most other collectors. Each shard is represented by a
  68. separate monitoring document.
  69. | Jobs | `job_stats`
  70. | Gathers details about all machine learning job statistics (for example, `GET
  71. /_ml/anomaly_detectors/_stats`). This information only needs to be collected
  72. once, so it is collected on the _elected_ master node. However, for the master
  73. node to be able to perform the collection, the master node must have
  74. `xpack.ml.enabled` set to true (default) and a license level that supports {ml}.
  75. | Node Stats | `node_stats`
  76. | Gathers details about the running node, such as memory utilization and CPU
  77. usage (for example, `GET /_nodes/_local/stats`). This runs on _every_ node with
  78. {monitor-features} enabled. One common failure results in the timeout of the node
  79. stats request due to too many segment files. As a result, the collector spends
  80. too much time waiting for the file system stats to be calculated until it
  81. finally times out. A single `node_stats` document is created per collection.
  82. This is collected per node to help to discover issues with nodes communicating
  83. with each other, but not with the monitoring cluster (for example, intermittent
  84. network issues or memory pressure).
  85. |=======================
  86. The {es} {monitor-features} use a single threaded scheduler to run the
  87. collection of {es} monitoring data by all of the appropriate collectors on each
  88. node. This scheduler is managed locally by each node and its interval is
  89. controlled by specifying the `xpack.monitoring.collection.interval`, which
  90. defaults to 10 seconds (`10s`), at either the node or cluster level.
  91. Fundamentally, each collector works on the same principle. Per collection
  92. interval, each collector is checked to see whether it should run and then the
  93. appropriate collectors run. The failure of an individual collector does not
  94. impact any other collector.
  95. Once collection has completed, all of the monitoring data is passed to the
  96. exporters to route the monitoring data to the monitoring clusters.
  97. If gaps exist in the monitoring charts in {kib}, it is typically because either
  98. a collector failed or the monitoring cluster did not receive the data (for
  99. example, it was being restarted). In the event that a collector fails, a logged
  100. error should exist on the node that attempted to perform the collection.
  101. NOTE: Collection is currently done serially, rather than in parallel, to avoid
  102. extra overhead on the elected master node. The downside to this approach
  103. is that collectors might observe a different version of the cluster state
  104. within the same collection period. In practice, this does not make a
  105. significant difference and running the collectors in parallel would not
  106. prevent such a possibility.
  107. For more information about the configuration options for the collectors, see
  108. <<monitoring-collection-settings>>.
  109. [discrete]
  110. [[es-monitoring-stack]]
  111. ==== Collecting data from across the Elastic Stack
  112. {es} {monitor-features} also receive monitoring data from other parts of the
  113. Elastic Stack. In this way, it serves as an unscheduled monitoring data
  114. collector for the stack.
  115. By default, data collection is disabled. {es} monitoring data is not
  116. collected and all monitoring data from other sources such as {kib}, Beats, and
  117. Logstash is ignored. You must set `xpack.monitoring.collection.enabled` to `true`
  118. to enable the collection of monitoring data. See <<monitoring-settings>>.
  119. Once data is received, it is forwarded to the exporters
  120. to be routed to the monitoring cluster like all monitoring data.
  121. WARNING: Because this stack-level "collector" lives outside of the collection
  122. interval of {es} {monitor-features}, it is not impacted by the
  123. `xpack.monitoring.collection.interval` setting. Therefore, data is passed to the
  124. exporters whenever it is received. This behavior can result in indices for {kib},
  125. Logstash, or Beats being created somewhat unexpectedly.
  126. While the monitoring data is collected and processed, some production cluster
  127. metadata is added to incoming documents. This metadata enables {kib} to link the
  128. monitoring data to the appropriate cluster. If this linkage is unimportant to
  129. the infrastructure that you're monitoring, it might be simpler to configure
  130. Logstash and Beats to report monitoring data directly to the monitoring cluster.
  131. This scenario also prevents the production cluster from adding extra overhead
  132. related to monitoring data, which can be very useful when there are a large
  133. number of Logstash nodes or Beats.
  134. For more information about typical monitoring architectures, see
  135. <<how-monitoring-works>>.