[[data-streams-get-lifecycle-stats]]
=== Get data stream lifecycle stats
++++
<titleabbrev>Get Data Stream Lifecycle</titleabbrev>
++++

preview::[]

Gets stats about the execution of data stream lifecycle.

[[get-lifecycle-stats-api-prereqs]]
==== {api-prereq-title}

* If the {es} {security-features} are enabled, you must have the `monitor` or
`manage` <<privileges-list-cluster,cluster privilege>> to use this API.

[[data-streams-get-lifecycle-stats-request]]
==== {api-request-title}

`GET _lifecycle/stats`

[[data-streams-get-lifecycle-stats-desc]]
==== {api-description-title}

Gets stats about the execution of the data stream lifecycle. The data stream level stats include only stats about data streams
managed by the data stream lifecycle.

[[get-lifecycle-stats-api-response-body]]
==== {api-response-body-title}

`last_run_duration_in_millis`::
(Optional, long)
The duration of the last data stream lifecycle execution.
`time_between_starts_in_millis`::
(Optional, long)
The time passed between the start of the last two data stream lifecycle executions. This should amount approximately to
<<data-streams-lifecycle-poll-interval,`data_streams.lifecycle.poll_interval`>>.
`data_stream_count`::
(integer)
The count of data streams currently being managed by the data stream lifecycle.
`data_streams`::
(array of objects)
Contains information about the retrieved data stream lifecycles.
+
.Properties of objects in `data_streams`
[%collapsible%open]
====
`name`::
(string)
The name of the data stream.
`backing_indices_in_total`::
(integer)
The count of the backing indices of this data stream that are managed by the data stream lifecycle.
`backing_indices_in_error`::
(integer)
The count of the backing indices of this data stream that are managed by the data stream lifecycle and have encountered an error.
====

[[data-streams-get-lifecycle-stats-example]]
==== {api-examples-title}

Let's retrieve the data stream lifecycle stats of a cluster that has already executed the lifecycle more than once:

[source,console]
--------------------------------------------------
GET _lifecycle/stats?human&pretty
--------------------------------------------------
// TEST[skip:this is for demonstration purposes only, we cannot ensure that DSL has run]

The response will look like the following:

[source,console-result]
--------------------------------------------------
{
  "last_run_duration_in_millis": 2,
  "last_run_duration": "2ms",
  "time_between_starts_in_millis": 9998,
  "time_between_starts": "9.99s",
  "data_streams_count": 2,
  "data_streams": [
    {
      "name": "my-data-stream",
      "backing_indices_in_total": 2,
      "backing_indices_in_error": 0
    },
    {
      "name": "my-other-stream",
      "backing_indices_in_total": 2,
      "backing_indices_in_error": 1
    }
  ]
}
--------------------------------------------------