explain-lifecycle.asciidoc 4.7 KB

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