collectors.asciidoc 8.0 KB

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