---
type: api
title: Get datafeed stats
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-get-datafeed-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-get-datafeed-stats
products:
  - Elasticsearch
---

# Get datafeed stats


Availability: 5.5+

## Paths

- `GET` `/_ml/datafeeds/{datafeed_id}/_stats`
- `GET` `/_ml/datafeeds/_stats`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `datafeed_id` (union Id | [] Id) — optional, leave it out to use `/_ml/datafeeds/_stats`
  Identifier for the datafeed. It can be a datafeed identifier or a
wildcard expression. If you do not specify one of these options, the API
returns information about all datafeeds.

## Description

You can get statistics for multiple datafeeds in a single API request by
using a comma-separated list of datafeeds or a wildcard expression. You can
get statistics for all datafeeds by using `_all`, by specifying `*` as the
`<feed_id>`, or by omitting the `<feed_id>`. If the datafeed is stopped, the
only information you receive is the `datafeed_id` and the `state`.
This API returns a maximum of 10,000 datafeeds.

## Required authorization

* Cluster privileges: `monitor_ml`

## Query String Parameters

- `allow_no_match` (boolean)
  Specifies what to do when the request:

1. Contains wildcard expressions and there are no datafeeds that match.
2. Contains the `_all` string or no identifiers and there are no matches.
3. Contains wildcard expressions and there are only partial matches.

The default value is `true`, which returns an empty `datafeeds` array
when there are no matches and the subset of results when there are
partial matches. If this parameter is `false`, the request returns a
`404` status code when there are no matches or only partial matches.

## Response

`application/json`

- `count` (number)
- `datafeeds` ([] DatafeedStats)
  - `assignment_explanation` (string)
    For started datafeeds only, contains messages relating to the selection of a node.
  - `datafeed_id` (string Id)
    A numerical character string that uniquely identifies the datafeed.
This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores.
It must start and end with alphanumeric characters.
  - `node` ({} DiscoveryNodeCompact)
    For started datafeeds only, this information pertains to the node upon which the datafeed is started.
    - `name` (string Name)
    - `ephemeral_id` (string Id)
    - `id` (string Id)
    - `transport_address` (string)
    - `attributes` (map string to string)
  - `state` (enum DatafeedState)
    The status of the datafeed, which can be one of the following values: `starting`, `started`, `stopping`, `stopped`.
    Values: `started`, `stopped`, `starting`, `stopping`
  - `timing_stats` ({} DatafeedTimingStats)
    An object that provides statistical information about timing aspect of this datafeed.
    - `bucket_count` (number)
      The number of buckets processed.
    - `exponential_average_search_time_per_hour_ms` (DurationValueUnitFloatMillis)
      The exponential average search time per hour, in milliseconds.
    - `exponential_average_calculation_context` ({} ExponentialAverageCalculationContext)
      - `incremental_metric_value_ms` (DurationValueUnitFloatMillis)
      - `latest_timestamp` (EpochTimeUnitMillis)
      - `previous_exponential_average_ms` (DurationValueUnitFloatMillis)
    - `job_id` (string Id)
      Identifier for the anomaly detection job.
    - `search_count` (number)
      The number of searches run by the datafeed.
    - `total_search_time_ms` (DurationValueUnitFloatMillis)
      The total time the datafeed spent searching, in milliseconds.
    - `average_search_time_per_bucket_ms` (DurationValueUnitFloatMillis)
      The average search time per bucket, in milliseconds.
  - `running_state` ({} DatafeedRunningState)
    An object containing the running state for this datafeed.
It is only provided if the datafeed is started.
    - `real_time_configured` (boolean)
      Indicates if the datafeed is "real-time"; meaning that the datafeed has no configured `end` time.
    - `real_time_running` (boolean)
      Indicates whether the datafeed has finished running on the available past data.
For datafeeds without a configured `end` time, this means that the datafeed is now running on "real-time" data.
    - `search_interval` ({} RunningStateSearchInterval)
      Provides the latest time interval the datafeed has searched.
      - `end` (string Duration)
        The end time.
      - `end_ms` (DurationValueUnitMillis)
        The end time as an epoch in milliseconds.
      - `start` (string Duration)
        The start time.
      - `start_ms` (DurationValueUnitMillis)
        The start time as an epoch in milliseconds.
## Code Examples

#### Console

```console
GET _ml/datafeeds/datafeed-high_sum_total_sales/_stats
```

#### JavaScript

```javascript
const response = await client.ml.getDatafeedStats({
  datafeed_id: "datafeed-high_sum_total_sales",
});
```

#### Python

```python
resp = client.ml.get_datafeed_stats(
    datafeed_id="datafeed-high_sum_total_sales",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_stats" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().getDatafeedStats(g -> g
    .datafeedId("datafeed-high_sum_total_sales")
);
```

#### C#

```c#
var response = await client.MachineLearning
    .GetDatafeedStatsAsync(d1 => d1
        .DatafeedId(new[] { "datafeed-high_sum_total_sales" })
    );
```

#### PHP

```php
$resp = $client->ml()->getDatafeedStats([
    "datafeed_id" => "datafeed-high_sum_total_sales",
]);
```

#### Ruby

```ruby
response = client.ml.get_datafeed_stats(
  datafeed_id: "datafeed-high_sum_total_sales"
)
```

