get-follow-stats.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. [role="xpack"]
  2. [[ccr-get-follow-stats]]
  3. === Get follower stats API
  4. ++++
  5. <titleabbrev>Get follower stats</titleabbrev>
  6. ++++
  7. ..New API reference
  8. [sidebar]
  9. --
  10. For the most up-to-date API details, refer to {api-es}/group/endpoint-ccr[Cross-cluster replication APIs].
  11. --
  12. Get <<xpack-ccr,{ccr}>> follower stats.
  13. [[ccr-get-follow-stats-request]]
  14. ==== {api-request-title}
  15. //////////////////////////
  16. [source,console]
  17. --------------------------------------------------
  18. PUT /follower_index/_ccr/follow?wait_for_active_shards=1
  19. {
  20. "remote_cluster" : "remote_cluster",
  21. "leader_index" : "leader_index"
  22. }
  23. --------------------------------------------------
  24. // TESTSETUP
  25. // TEST[setup:remote_cluster_and_leader_index]
  26. [source,console]
  27. --------------------------------------------------
  28. POST /follower_index/_ccr/pause_follow
  29. --------------------------------------------------
  30. // TEARDOWN
  31. //////////////////////////
  32. [source,console]
  33. --------------------------------------------------
  34. GET /<index>/_ccr/stats
  35. --------------------------------------------------
  36. // TEST[s/<index>/follower_index/]
  37. [[ccr-get-follow-stats-prereqs]]
  38. ==== {api-prereq-title}
  39. * If the {es} {security-features} are enabled, you must have `monitor` cluster
  40. privileges on the cluster that contains the follower index. For more information,
  41. see <<security-privileges>>.
  42. [[ccr-get-follow-stats-desc]]
  43. ==== {api-description-title}
  44. This API gets follower stats. This API will return shard-level stats about the
  45. following tasks associated with each shard for the specified indices.
  46. [[ccr-get-follow-stats-path-parms]]
  47. ==== {api-path-parms-title}
  48. `<index>`::
  49. (Required, string) A comma-delimited list of index patterns.
  50. [[ccr-get-follow-stats-query-params]]
  51. ==== {api-query-parms-title}
  52. `timeout`::
  53. (Optional, time) Controls the amount of time to wait for results. Defaults to unlimited.
  54. [role="child_attributes"]
  55. [[ccr-get-follow-stats-response-body]]
  56. ==== {api-response-body-title}
  57. //Begin indices
  58. `indices`::
  59. (array) An array of follower index statistics.
  60. +
  61. .Properties of `indices`
  62. [%collapsible%open]
  63. ====
  64. `fatal_exception`::
  65. (object) An object representing a fatal exception that cancelled the following
  66. task. In this situation, the following task must be resumed manually with the
  67. <<ccr-post-resume-follow,resume follower API>>.
  68. `index`::
  69. (string) The name of the follower index.
  70. `total_global_checkpoint_lag`::
  71. (long) Indication of how much the follower is lagging the leader. This is the sum of the difference between the `leader_global_checkpoint` and the `follower_global_checkpoint` for all shards.
  72. //Begin shards
  73. `shards`::
  74. (array) An array of shard-level following task statistics.
  75. +
  76. .Properties of objects in `shards`
  77. [%collapsible%open]
  78. =====
  79. `bytes_read`::
  80. (long) The total of transferred bytes read from the leader.
  81. +
  82. --
  83. NOTE: This is only an estimate and does not account for compression if enabled.
  84. --
  85. `failed_read_requests`::
  86. (long) The number of failed reads.
  87. `failed_write_requests`::
  88. (long) The number of failed bulk write requests executed on the follower.
  89. `follower_aliases_version`::
  90. (long) The index aliases version the follower is synced up to.
  91. `follower_global_checkpoint`::
  92. (long) The current global checkpoint on the follower. The difference between the
  93. `leader_global_checkpoint` and the `follower_global_checkpoint` is an
  94. indication of how much the follower is lagging the leader.
  95. `follower_index`::
  96. (string) The name of the follower index.
  97. `follower_mapping_version`::
  98. (long) The mapping version the follower is synced up to.
  99. `follower_max_seq_no`::
  100. (long) The current maximum sequence number on the follower.
  101. `follower_settings_version`::
  102. (long) The index settings version the follower is synced up to.
  103. `last_requested_seq_no`::
  104. (long) The starting sequence number of the last batch of operations requested
  105. from the leader.
  106. `leader_global_checkpoint`::
  107. (long) The current global checkpoint on the leader known to the follower task.
  108. `leader_index`::
  109. (string) The name of the index in the leader cluster being followed.
  110. `leader_max_seq_no`::
  111. (long) The current maximum sequence number on the leader known to the follower
  112. task.
  113. `operations_read`::
  114. (long) The total number of operations read from the leader.
  115. `operations_written`::
  116. (long) The number of operations written on the follower.
  117. `outstanding_read_requests`::
  118. (integer) The number of active read requests from the follower.
  119. `outstanding_write_requests`::
  120. (integer) The number of active bulk write requests on the follower.
  121. //Begin read_exceptions
  122. `read_exceptions`::
  123. (array) An array of objects representing failed reads.
  124. +
  125. .Properties of objects in `read_exceptions`
  126. [%collapsible%open]
  127. ======
  128. `exception`::
  129. (object) Represents the exception that caused the read to fail.
  130. `from_seq_no`::
  131. (long) The starting sequence number of the batch requested from the leader.
  132. `retries`::
  133. (integer) The number of times the batch has been retried.
  134. ======
  135. //End read_exceptions
  136. `remote_cluster`::
  137. (string) The <<remote-clusters,remote cluster>> containing the leader
  138. index.
  139. `shard_id`::
  140. (integer) The numerical shard ID, with values from 0 to one less than the
  141. number of replicas.
  142. `successful_read_requests`::
  143. (long) The number of successful fetches.
  144. `successful_write_requests`::
  145. (long) The number of bulk write requests executed on the follower.
  146. `time_since_last_read_millis`::
  147. (long) The number of milliseconds since a read request was sent to the leader.
  148. +
  149. NOTE: When the follower is caught up to the leader, this number will increase up
  150. to the configured `read_poll_timeout` at which point another read request will
  151. be sent to the leader.
  152. `total_read_remote_exec_time_millis`::
  153. (long) The total time reads spent executing on the remote cluster.
  154. `total_read_time_millis`::
  155. (long) The total time reads were outstanding, measured from the time a read was
  156. sent to the leader to the time a reply was returned to the follower.
  157. `total_write_time_millis`::
  158. (long) The total time spent writing on the follower.
  159. `write_buffer_operation_count`::
  160. (integer) The number of write operations queued on the follower.
  161. `write_buffer_size_in_bytes`::
  162. (long) The total number of bytes of operations currently queued for writing.
  163. =====
  164. //End shards
  165. ====
  166. //End indices
  167. [[ccr-get-follow-stats-examples]]
  168. ==== {api-examples-title}
  169. This example retrieves follower stats:
  170. [source,console]
  171. --------------------------------------------------
  172. GET /follower_index/_ccr/stats
  173. --------------------------------------------------
  174. The API returns the following results:
  175. [source,console-result]
  176. --------------------------------------------------
  177. {
  178. "indices" : [
  179. {
  180. "index" : "follower_index",
  181. "total_global_checkpoint_lag" : 256,
  182. "shards" : [
  183. {
  184. "remote_cluster" : "remote_cluster",
  185. "leader_index" : "leader_index",
  186. "follower_index" : "follower_index",
  187. "shard_id" : 0,
  188. "leader_global_checkpoint" : 1024,
  189. "leader_max_seq_no" : 1536,
  190. "follower_global_checkpoint" : 768,
  191. "follower_max_seq_no" : 896,
  192. "last_requested_seq_no" : 897,
  193. "outstanding_read_requests" : 8,
  194. "outstanding_write_requests" : 2,
  195. "write_buffer_operation_count" : 64,
  196. "follower_mapping_version" : 4,
  197. "follower_settings_version" : 2,
  198. "follower_aliases_version" : 8,
  199. "total_read_time_millis" : 32768,
  200. "total_read_remote_exec_time_millis" : 16384,
  201. "successful_read_requests" : 32,
  202. "failed_read_requests" : 0,
  203. "operations_read" : 896,
  204. "bytes_read" : 32768,
  205. "total_write_time_millis" : 16384,
  206. "write_buffer_size_in_bytes" : 1536,
  207. "successful_write_requests" : 16,
  208. "failed_write_requests" : 0,
  209. "operations_written" : 832,
  210. "read_exceptions" : [ ],
  211. "time_since_last_read_millis" : 8
  212. }
  213. ]
  214. }
  215. ]
  216. }
  217. --------------------------------------------------
  218. // TESTRESPONSE[s/"total_global_checkpoint_lag" : 256/"total_global_checkpoint_lag" : 0/]
  219. // TESTRESPONSE[s/"leader_global_checkpoint" : 1024/"leader_global_checkpoint" : $body.indices.0.shards.0.leader_global_checkpoint/]
  220. // TESTRESPONSE[s/"leader_max_seq_no" : 1536/"leader_max_seq_no" : $body.indices.0.shards.0.leader_max_seq_no/]
  221. // TESTRESPONSE[s/"follower_global_checkpoint" : 768/"follower_global_checkpoint" : $body.indices.0.shards.0.follower_global_checkpoint/]
  222. // TESTRESPONSE[s/"follower_max_seq_no" : 896/"follower_max_seq_no" : $body.indices.0.shards.0.follower_max_seq_no/]
  223. // TESTRESPONSE[s/"last_requested_seq_no" : 897/"last_requested_seq_no" : $body.indices.0.shards.0.last_requested_seq_no/]
  224. // TESTRESPONSE[s/"outstanding_read_requests" : 8/"outstanding_read_requests" : $body.indices.0.shards.0.outstanding_read_requests/]
  225. // TESTRESPONSE[s/"outstanding_write_requests" : 2/"outstanding_write_requests" : $body.indices.0.shards.0.outstanding_write_requests/]
  226. // TESTRESPONSE[s/"write_buffer_operation_count" : 64/"write_buffer_operation_count" : $body.indices.0.shards.0.write_buffer_operation_count/]
  227. // TESTRESPONSE[s/"follower_mapping_version" : 4/"follower_mapping_version" : $body.indices.0.shards.0.follower_mapping_version/]
  228. // TESTRESPONSE[s/"follower_settings_version" : 2/"follower_settings_version" : $body.indices.0.shards.0.follower_settings_version/]
  229. // TESTRESPONSE[s/"follower_aliases_version" : 8/"follower_aliases_version" : $body.indices.0.shards.0.follower_aliases_version/]
  230. // TESTRESPONSE[s/"total_read_time_millis" : 32768/"total_read_time_millis" : $body.indices.0.shards.0.total_read_time_millis/]
  231. // TESTRESPONSE[s/"total_read_remote_exec_time_millis" : 16384/"total_read_remote_exec_time_millis" : $body.indices.0.shards.0.total_read_remote_exec_time_millis/]
  232. // TESTRESPONSE[s/"successful_read_requests" : 32/"successful_read_requests" : $body.indices.0.shards.0.successful_read_requests/]
  233. // TESTRESPONSE[s/"failed_read_requests" : 0/"failed_read_requests" : $body.indices.0.shards.0.failed_read_requests/]
  234. // TESTRESPONSE[s/"operations_read" : 896/"operations_read" : $body.indices.0.shards.0.operations_read/]
  235. // TESTRESPONSE[s/"bytes_read" : 32768/"bytes_read" : $body.indices.0.shards.0.bytes_read/]
  236. // TESTRESPONSE[s/"total_write_time_millis" : 16384/"total_write_time_millis" : $body.indices.0.shards.0.total_write_time_millis/]
  237. // TESTRESPONSE[s/"write_buffer_size_in_bytes" : 1536/"write_buffer_size_in_bytes" : $body.indices.0.shards.0.write_buffer_size_in_bytes/]
  238. // TESTRESPONSE[s/"successful_write_requests" : 16/"successful_write_requests" : $body.indices.0.shards.0.successful_write_requests/]
  239. // TESTRESPONSE[s/"failed_write_requests" : 0/"failed_write_requests" : $body.indices.0.shards.0.failed_write_requests/]
  240. // TESTRESPONSE[s/"operations_written" : 832/"operations_written" : $body.indices.0.shards.0.operations_written/]
  241. // TESTRESPONSE[s/"time_since_last_read_millis" : 8/"time_since_last_read_millis" : $body.indices.0.shards.0.time_since_last_read_millis/]