get-datafeed-stats.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-datafeed-stats]]
  4. === Get {dfeed} statistics API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Get {dfeed} statistics</titleabbrev>
  8. ++++
  9. Retrieves usage information for {dfeeds}.
  10. [[ml-get-datafeed-stats-request]]
  11. ==== {api-request-title}
  12. `GET _ml/datafeeds/<feed_id>/_stats` +
  13. `GET _ml/datafeeds/<feed_id>,<feed_id>/_stats` +
  14. `GET _ml/datafeeds/_stats` +
  15. `GET _ml/datafeeds/_all/_stats`
  16. [[ml-get-datafeed-stats-prereqs]]
  17. ==== {api-prereq-title}
  18. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  19. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. See
  20. {stack-ov}/security-privileges.html[Security privileges].
  21. [[ml-get-datafeed-stats-desc]]
  22. ==== {api-description-title}
  23. You can get statistics for multiple {dfeeds} in a single API request by using a
  24. comma-separated list of {dfeeds} or a wildcard expression. You can get
  25. statistics for all {dfeeds} by using `_all`, by specifying `*` as the
  26. `<feed_id>`, or by omitting the `<feed_id>`.
  27. If the {dfeed} is stopped, the only information you receive is the
  28. `datafeed_id` and the `state`.
  29. IMPORTANT: This API returns a maximum of 10,000 {dfeeds}.
  30. [[ml-get-datafeed-stats-path-parms]]
  31. ==== {api-path-parms-title}
  32. `<feed_id>`::
  33. (Optional, string) Identifier for the {dfeed}. It can be a {dfeed} identifier
  34. or a wildcard expression. If you do not specify one of these options, the API
  35. returns statistics for all {dfeeds}.
  36. [[ml-get-datafeed-stats-query-parms]]
  37. ==== {api-query-parms-title}
  38. `allow_no_datafeeds`::
  39. (Optional, boolean) Specifies what to do when the request:
  40. +
  41. --
  42. * Contains wildcard expressions and there are no {datafeeds} that match.
  43. * Contains the `_all` string or no identifiers and there are no matches.
  44. * Contains wildcard expressions and there are only partial matches.
  45. The default value is `true`, which returns an empty `datafeeds` array when
  46. there are no matches and the subset of results when there are partial matches.
  47. If this parameter is `false`, the request returns a `404` status code when there
  48. are no matches or only partial matches.
  49. --
  50. [[ml-get-datafeed-stats-results]]
  51. ==== {api-response-body-title}
  52. The API returns the following information:
  53. `datafeeds`::
  54. (array) An array of {dfeed} count objects.
  55. For more information, see <<ml-datafeed-counts>>.
  56. [[ml-get-datafeed-stats-response-codes]]
  57. ==== {api-response-codes-title}
  58. `404` (Missing resources)::
  59. If `allow_no_datafeeds` is `false`, this code indicates that there are no
  60. resources that match the request or only partial matches for the request.
  61. [[ml-get-datafeed-stats-example]]
  62. ==== {api-examples-title}
  63. The following example gets usage information for the
  64. `datafeed-total-requests` {dfeed}:
  65. [source,js]
  66. --------------------------------------------------
  67. GET _ml/datafeeds/datafeed-total-requests/_stats
  68. --------------------------------------------------
  69. // CONSOLE
  70. // TEST[skip:setup:server_metrics_startdf]
  71. The API returns the following results:
  72. [source,js]
  73. ----
  74. {
  75. "count": 1,
  76. "datafeeds": [
  77. {
  78. "datafeed_id": "datafeed-total-requests",
  79. "state": "started",
  80. "node": {
  81. "id": "2spCyo1pRi2Ajo-j-_dnPX",
  82. "name": "node-0",
  83. "ephemeral_id": "hoXMLZB0RWKfR9UPPUCxXX",
  84. "transport_address": "127.0.0.1:9300",
  85. "attributes": {
  86. "ml.machine_memory": "17179869184",
  87. "ml.max_open_jobs": "20"
  88. }
  89. },
  90. "assignment_explanation": "",
  91. "timing_stats": {
  92. "job_id": "job-total-requests",
  93. "search_count": 20,
  94. "total_search_time_ms": 120.5
  95. }
  96. }
  97. ]
  98. }
  99. ----
  100. // TESTRESPONSE[s/"2spCyo1pRi2Ajo-j-_dnPX"/$body.$_path/]
  101. // TESTRESPONSE[s/"node-0"/$body.$_path/]
  102. // TESTRESPONSE[s/"hoXMLZB0RWKfR9UPPUCxXX"/$body.$_path/]
  103. // TESTRESPONSE[s/"127.0.0.1:9300"/$body.$_path/]
  104. // TESTRESPONSE[s/"17179869184"/$body.datafeeds.0.node.attributes.ml\\.machine_memory/]