get-datafeed-stats.asciidoc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. [[java-rest-high-x-pack-ml-get-datafeed-stats]]
  2. === Get Datafeed Stats API
  3. The Get Datafeed Stats API provides the ability to get any number of
  4. {ml} datafeed's statistics in the cluster.
  5. It accepts a `GetDatafeedStatsRequest` object and responds
  6. with a `GetDatafeedStatsResponse` object.
  7. [[java-rest-high-x-pack-ml-get-datafeed-stats-request]]
  8. ==== Get Datafeed Stats Request
  9. A `GetDatafeedStatsRequest` object can have any number of `datafeedId`
  10. entries. However, they all must be non-null. An empty list is the same as
  11. requesting statistics for all datafeeds.
  12. ["source","java",subs="attributes,callouts,macros"]
  13. --------------------------------------------------
  14. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-request]
  15. --------------------------------------------------
  16. <1> Constructing a new request referencing existing `datafeedIds`, can contain wildcards
  17. <2> Whether to ignore if a wildcard expression matches no datafeeds.
  18. (This includes `_all` string or when no datafeeds have been specified)
  19. [[java-rest-high-x-pack-ml-get-datafeed-stats-execution]]
  20. ==== Execution
  21. The request can be executed through the `MachineLearningClient` contained
  22. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-execute]
  26. --------------------------------------------------
  27. [[java-rest-high-x-pack-ml-get-datafeed-stats-execution-async]]
  28. ==== Asynchronous Execution
  29. The request can also be executed asynchronously:
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-execute-async]
  33. --------------------------------------------------
  34. <1> The `GetDatafeedStatsRequest` to execute and the `ActionListener` to use when
  35. the execution completes
  36. The method does not block and returns immediately. The passed `ActionListener` is used
  37. to notify the caller of completion. A typical `ActionListener` for `GetDatafeedStatsResponse` may
  38. look like
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-listener]
  42. --------------------------------------------------
  43. <1> `onResponse` is called back when the action is completed successfully
  44. <2> `onFailure` is called back when some unexpected error occurs
  45. [[java-rest-high-x-pack-ml-get-datafeed-stats-response]]
  46. ==== Get Datafeed Stats Response
  47. The returned `GetDatafeedStatsResponse` contains the requested datafeed statistics:
  48. ["source","java",subs="attributes,callouts,macros"]
  49. --------------------------------------------------
  50. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-response]
  51. --------------------------------------------------
  52. <1> `count()` indicates the number of datafeeds statistics found
  53. <2> `datafeedStats()` is the collection of {ml} `DatafeedStats` objects found