--
:api: get-datafeed-stats
:request: GetDatafeedStatsRequest
:response: GetDatafeedStatsResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Get datafeed stats API

Retrieves any number of {ml} datafeeds' statistics in the cluster.
It accepts a +{request}+ object and responds with a +{response}+ object.

[id="{upid}-{api}-request"]
==== Get datafeed stats request

A +{request}+ object can have any number of `datafeedId` entries. However, they
all must be non-null. An empty list is the same as requesting statistics for all
datafeeds.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Constructing a new request referencing existing `datafeedIds`. It can
contain wildcards.
<2> Whether to ignore if a wildcard expression matches no datafeeds.
 (This includes `_all` string or when no datafeeds have been specified).

include::../execution.asciidoc[]

[id="{upid}-{api}-response"]
==== Get datafeed stats response
The returned +{response}+ contains the requested datafeed statistics:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> `count()` indicates the number of datafeeds statistics found.
<2> `datafeedStats()` is the collection of {ml} `DatafeedStats` objects found.