explain-lifecycle.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. [[data-streams-explain-lifecycle]]
  2. === Explain data stream lifecycle
  3. ++++
  4. <titleabbrev>Explain Data Stream Lifecycle</titleabbrev>
  5. ++++
  6. .New API reference
  7. [sidebar]
  8. --
  9. For the most up-to-date API details, refer to {api-es}/group/endpoint-data-stream[Data stream APIs].
  10. --
  11. Retrieves the current <<data-stream-lifecycle,data stream lifecycle>> status for one or more data stream backing indices.
  12. [[explain-lifecycle-api-prereqs]]
  13. ==== {api-prereq-title}
  14. If the {es} {security-features} are enabled, you must have at least the `manage_data_stream_lifecycle` index privilege or
  15. `view_index_metadata` index privilege to use this API. For more information, see <<security-privileges>>.
  16. [[data-streams-explain-lifecycle-request]]
  17. ==== {api-request-title}
  18. `GET <target>/_lifecycle/explain`
  19. [[data-streams-explain-lifecycle-desc]]
  20. ==== {api-description-title}
  21. Retrieves information about the index or data stream's current data stream lifecycle state, such as
  22. time since index creation, time since rollover, the lifecycle configuration
  23. managing the index, or any error that {es} might've encountered during the lifecycle
  24. execution.
  25. [[data-streams-explain-lifecycle-path-params]]
  26. ==== {api-path-parms-title}
  27. `<target>`::
  28. (Required, string) Comma-separated list of indices or data streams.
  29. [[data-streams-explain-lifecycle-query-params]]
  30. ==== {api-query-parms-title}
  31. `include_defaults`::
  32. (Optional, Boolean) Includes default configurations related to the lifecycle of the target.
  33. Defaults to `false`.
  34. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  35. [[data-streams-explain-lifecycle-example]]
  36. ==== {api-examples-title}
  37. If you want to retrieve the lifecycle state of all the backing indices of a data stream, you can use the data stream name.
  38. For simplicity, the following example retrieves the lifecycle state of one backing index `.ds-metrics-2023.03.22-000001`:
  39. [source,console]
  40. --------------------------------------------------
  41. GET .ds-metrics-2023.03.22-000001/_lifecycle/explain
  42. --------------------------------------------------
  43. // TEST[skip:we're not setting up data stream lifecycle in these tests]
  44. If the index is managed by a data stream lifecycle `explain` will show the `managed_by_lifecycle` field
  45. set to `true` and the rest of the response will contain information about the
  46. lifecycle execution status for this index:
  47. [source,console-result]
  48. --------------------------------------------------
  49. {
  50. "indices": {
  51. ".ds-metrics-2023.03.22-000001": {
  52. "index" : ".ds-metrics-2023.03.22-000001",
  53. "managed_by_lifecycle" : true, <1>
  54. "index_creation_date_millis" : 1679475563571, <2>
  55. "time_since_index_creation" : "843ms", <3>
  56. "rollover_date_millis" : 1679475564293, <4>
  57. "time_since_rollover" : "121ms", <5>
  58. "lifecycle" : { }, <6>
  59. "generation_time" : "121ms" <7>
  60. }
  61. }
  62. --------------------------------------------------
  63. // TESTRESPONSE[skip:the result is for illustrating purposes only]
  64. <1> Shows if the index is being managed by data stream lifecycle. If the index is not managed by
  65. a data stream lifecycle the other fields will not be shown
  66. <2> When the index was created, this timestamp is used to determine when to
  67. rollover
  68. <3> The time since the index creation (used for calculating when to rollover
  69. the index via the `max_age`)
  70. <4> When the index was rolled over. If the index was not rolled over this will not be
  71. shown.
  72. <5> The time since rollover. If the index was not rolled over this will not be shown.
  73. <6> The lifecycle configuration that applies to this index (which is configured on the parent
  74. data stream)
  75. <7> The generation time of the index represents the time since the index started progressing
  76. towards the user configurable / business specific parts of the lifecycle (e.g. retention).
  77. The `generation_time` is calculated from the origination date if it exists, or from the
  78. rollover date if it exists, or from the creation date if neither of the other two exist.
  79. If the index is the write index the `generation_time` will not be reported because it is not
  80. eligible for retention or other parts of the lifecycle.
  81. The `explain` will also report any errors related to the lifecycle execution for the target
  82. index:
  83. [source,console-result]
  84. --------------------------------------------------
  85. {
  86. "indices": {
  87. ".ds-metrics-2023.03.22-000001": {
  88. "index" : ".ds-metrics-2023.03.22-000001",
  89. "managed_by_lifecycle" : true,
  90. "index_creation_date_millis" : 1679475563571,
  91. "time_since_index_creation" : "843ms",
  92. "lifecycle" : {
  93. "enabled": true
  94. },
  95. "error": "{\"type\":\"validation_exception\",\"reason\":\"Validation Failed: 1: this action would add [2] shards, but this cluster
  96. currently has [4]/[3] maximum normal shards open;\"}" <1>
  97. }
  98. }
  99. --------------------------------------------------
  100. // TESTRESPONSE[skip:the result is for illustrating purposes only]
  101. <1> The target index could not be rolled over due to a limitation in the number of shards
  102. allowed in the cluster.