get-job-stats.asciidoc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-job-stats]]
  4. === Get {anomaly-job} statistics API
  5. ++++
  6. <titleabbrev>Get job statistics</titleabbrev>
  7. ++++
  8. Retrieves usage information for {anomaly-jobs}.
  9. [[ml-get-job-stats-request]]
  10. ==== {api-request-title}
  11. `GET _ml/anomaly_detectors/<job_id>/_stats`
  12. `GET _ml/anomaly_detectors/<job_id>,<job_id>/_stats` +
  13. `GET _ml/anomaly_detectors/_stats` +
  14. `GET _ml/anomaly_detectors/_all/_stats`
  15. [[ml-get-job-stats-prereqs]]
  16. ==== {api-prereq-title}
  17. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  18. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. See
  19. <<security-privileges>>.
  20. [[ml-get-job-stats-desc]]
  21. ==== {api-description-title}
  22. You can get statistics for multiple {anomaly-jobs} in a single API request by
  23. using a group name, a comma-separated list of jobs, or a wildcard expression.
  24. You can get statistics for all {anomaly-jobs} by using `_all`, by specifying `*`
  25. as the `<job_id>`, or by omitting the `<job_id>`.
  26. IMPORTANT: This API returns a maximum of 10,000 jobs.
  27. [[ml-get-job-stats-path-parms]]
  28. ==== {api-path-parms-title}
  29. `<job_id>`::
  30. (Optional, string)
  31. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-default]
  32. [[ml-get-job-stats-query-parms]]
  33. ==== {api-query-parms-title}
  34. `allow_no_jobs`::
  35. (Optional, boolean)
  36. include::{docdir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
  37. [[ml-get-job-stats-results]]
  38. ==== {api-response-body-title}
  39. The API returns the following information about the operational progress of a
  40. job:
  41. `assignment_explanation`::
  42. (string)
  43. include::{docdir}/ml/ml-shared.asciidoc[tag=assignment-explanation-anomaly-jobs]
  44. [[datacounts]]`data_counts`::
  45. (object) An object that describes the quantity of input to the job and any
  46. related error counts. The `data_count` values are cumulative for the lifetime of
  47. a job. If a model snapshot is reverted or old results are deleted, the job
  48. counts are not reset.
  49. `data_counts`.`bucket_count`:::
  50. (long)
  51. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-count-anomaly-jobs]
  52. `data_counts`.`earliest_record_timestamp`:::
  53. (date)
  54. include::{docdir}/ml/ml-shared.asciidoc[tag=earliest-record-timestamp]
  55. `data_counts`.`empty_bucket_count`:::
  56. (long)
  57. include::{docdir}/ml/ml-shared.asciidoc[tag=empty-bucket-count]
  58. `data_counts`.`input_bytes`:::
  59. (long)
  60. include::{docdir}/ml/ml-shared.asciidoc[tag=input-bytes]
  61. `data_counts`.`input_field_count`:::
  62. (long)
  63. include::{docdir}/ml/ml-shared.asciidoc[tag=input-field-count]
  64. `data_counts`.`input_record_count`:::
  65. (long)
  66. include::{docdir}/ml/ml-shared.asciidoc[tag=input-record-count]
  67. `data_counts`.`invalid_date_count`:::
  68. (long)
  69. include::{docdir}/ml/ml-shared.asciidoc[tag=invalid-date-count]
  70. `data_counts`.`job_id`:::
  71. (string)
  72. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  73. `data_counts`.`last_data_time`:::
  74. (date)
  75. include::{docdir}/ml/ml-shared.asciidoc[tag=last-data-time]
  76. `data_counts`.`latest_empty_bucket_timestamp`:::
  77. (date)
  78. include::{docdir}/ml/ml-shared.asciidoc[tag=latest-empty-bucket-timestamp]
  79. `data_counts`.`latest_record_timestamp`:::
  80. (date)
  81. include::{docdir}/ml/ml-shared.asciidoc[tag=latest-record-timestamp]
  82. `data_counts`.`latest_sparse_bucket_timestamp`:::
  83. (date)
  84. include::{docdir}/ml/ml-shared.asciidoc[tag=latest-sparse-record-timestamp]
  85. `data_counts`.`missing_field_count`:::
  86. (long)
  87. include::{docdir}/ml/ml-shared.asciidoc[tag=missing-field-count]
  88. +
  89. The value of `processed_record_count` includes this count.
  90. `data_counts`.`out_of_order_timestamp_count`:::
  91. (long)
  92. include::{docdir}/ml/ml-shared.asciidoc[tag=out-of-order-timestamp-count]
  93. `data_counts`.`processed_field_count`:::
  94. include::{docdir}/ml/ml-shared.asciidoc[tag=processed-field-count]
  95. `data_counts`.`processed_record_count`:::
  96. (long)
  97. include::{docdir}/ml/ml-shared.asciidoc[tag=processed-record-count]
  98. `data_counts`.`sparse_bucket_count`:::
  99. (long)
  100. include::{docdir}/ml/ml-shared.asciidoc[tag=sparse-bucket-count]
  101. `deleting`::
  102. (boolean)
  103. Indicates that the process of deleting the job is in progress but not yet
  104. completed. It is only reported when `true`.
  105. [[forecastsstats]]`forecasts_stats`::
  106. (object) An object that provides statistical information about forecasts
  107. belonging to this job. Some statistics are omitted if no forecasts have been
  108. made. It has the following properties:
  109. +
  110. --
  111. NOTE: Unless there is at least one forecast, `memory_bytes`, `records`,
  112. `processing_time_ms` and `status` properties are omitted.
  113. --
  114. `forecasts_stats`.`forecasted_jobs`:::
  115. (long) A value of `0` indicates that forecasts do not exist for this job. A
  116. value of `1` indicates that at least one forecast exists.
  117. `forecasts_stats`.`memory_bytes`:::
  118. (object) The `avg`, `min`, `max` and `total` memory usage in bytes for forecasts
  119. related to this job. If there are no forecasts, this property is omitted.
  120. `forecasts_stats`.`records`:::
  121. (object) The `avg`, `min`, `max` and `total` number of `model_forecast` documents
  122. written for forecasts related to this job. If there are no forecasts, this
  123. property is omitted.
  124. `forecasts_stats`.`processing_time_ms`:::
  125. (object) The `avg`, `min`, `max` and `total` runtime in milliseconds for
  126. forecasts related to this job. If there are no forecasts, this property is omitted.
  127. `forecasts_stats`.`status`:::
  128. (object) The count of forecasts by their status. For example:
  129. {"finished" : 2, "started" : 1}. If there are no forecasts, this property is omitted.
  130. `forecasts_stats`.`total`:::
  131. (long)
  132. include::{docdir}/ml/ml-shared.asciidoc[tag=forecast-total]
  133. `job_id`::
  134. (string)
  135. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  136. [[modelsizestats]]`model_size_stats`::
  137. (object) An object that provides information about the size and contents of the
  138. model. It has the following properties:
  139. `model_size_stats`.`bucket_allocation_failures_count`:::
  140. (long)
  141. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-allocation-failures-count]
  142. `model_size_stats`.`categorized_doc_count`:::
  143. (long)
  144. include::{docdir}/ml/ml-shared.asciidoc[tag=categorized-doc-count]
  145. `model_size_stats`.`categorization_status`:::
  146. (string)
  147. include::{docdir}/ml/ml-shared.asciidoc[tag=categorization-status]
  148. `model_size_stats`.`dead_category_count`:::
  149. (long)
  150. include::{docdir}/ml/ml-shared.asciidoc[tag=dead-category-count]
  151. `model_size_stats`.`frequent_category_count`:::
  152. (long)
  153. include::{docdir}/ml/ml-shared.asciidoc[tag=frequent-category-count]
  154. `model_size_stats`.`job_id`:::
  155. (string)
  156. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  157. `model_size_stats`.`log_time`:::
  158. (date) The timestamp of the `model_size_stats` according to server time.
  159. `model_size_stats`.`memory_status`:::
  160. (string)
  161. include::{docdir}/ml/ml-shared.asciidoc[tag=model-memory-status]
  162. `model_size_stats`.`model_bytes`:::
  163. (long)
  164. include::{docdir}/ml/ml-shared.asciidoc[tag=model-bytes]
  165. `model_size_stats`.`model_bytes_exceeded`:::
  166. (long)
  167. include::{docdir}/ml/ml-shared.asciidoc[tag=model-bytes-exceeded]
  168. `model_size_stats`.`model_bytes_memory_limit`:::
  169. (long)
  170. include::{docdir}/ml/ml-shared.asciidoc[tag=model-memory-limit-anomaly-jobs]
  171. `model_size_stats`.`rare_category_count`:::
  172. (long)
  173. include::{docdir}/ml/ml-shared.asciidoc[tag=rare-category-count]
  174. `model_size_stats`.`result_type`:::
  175. (string) For internal use. The type of result.
  176. `model_size_stats`.`total_by_field_count`:::
  177. (long)
  178. include::{docdir}/ml/ml-shared.asciidoc[tag=total-by-field-count]
  179. `model_size_stats`.`total_category_count`:::
  180. (long)
  181. include::{docdir}/ml/ml-shared.asciidoc[tag=total-category-count]
  182. `model_size_stats`.`total_over_field_count`:::
  183. (long)
  184. include::{docdir}/ml/ml-shared.asciidoc[tag=total-over-field-count]
  185. `model_size_stats`.`total_partition_field_count`:::
  186. (long)
  187. include::{docdir}/ml/ml-shared.asciidoc[tag=total-partition-field-count]
  188. `model_size_stats`.`timestamp`:::
  189. (date)
  190. include::{docdir}/ml/ml-shared.asciidoc[tag=model-timestamp]
  191. [[stats-node]]`node`::
  192. (object) Contains properties for the node that runs the job. This information is
  193. available only for open jobs.
  194. `node`.`attributes`:::
  195. (object) Lists node attributes. For example,
  196. `{"ml.machine_memory": "17179869184", "ml.max_open_jobs" : "20"}`.
  197. `node`.`ephemeral_id`:::
  198. (string)
  199. include::{docdir}/ml/ml-shared.asciidoc[tag=node-ephemeral-id]
  200. `node`.`id`:::
  201. (string)
  202. include::{docdir}/ml/ml-shared.asciidoc[tag=node-id]
  203. `node`.`name`:::
  204. (string) The node name.
  205. `node`.`transport_address`:::
  206. (string) The host and port where transport HTTP connections are accepted.
  207. `open_time`::
  208. (string)
  209. include::{docdir}/ml/ml-shared.asciidoc[tag=open-time]
  210. `state`::
  211. (string)
  212. include::{docdir}/ml/ml-shared.asciidoc[tag=state-anomaly-job]
  213. [[timingstats]]`timing_stats`::
  214. (object) An object that provides statistical information about timing aspect of
  215. this job. It has the following properties:
  216. `timing_stats`.`average_bucket_processing_time_ms`:::
  217. (double) Average of all bucket processing times in milliseconds.
  218. `timing_stats`.`bucket_count`:::
  219. (long)
  220. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-count]
  221. `timing_stats`.`exponential_average_bucket_processing_time_ms`:::
  222. (double)
  223. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-time-exponential-average]
  224. `timing_stats`.`exponential_average_bucket_processing_time_per_hour_ms`:::
  225. (double)
  226. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-time-exponential-average-hour]
  227. `timing_stats`.`job_id`:::
  228. (string)
  229. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  230. `timing_stats`.`maximum_bucket_processing_time_ms`:::
  231. (double)
  232. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-time-maximum]
  233. `timing_stats`.`minimum_bucket_processing_time_ms`:::
  234. (double)
  235. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-time-minimum]
  236. `timing_stats`.`total_bucket_processing_time_ms`:::
  237. (double)
  238. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-time-total]
  239. [[ml-get-job-stats-response-codes]]
  240. ==== {api-response-codes-title}
  241. `404` (Missing resources)::
  242. If `allow_no_jobs` is `false`, this code indicates that there are no
  243. resources that match the request or only partial matches for the request.
  244. [[ml-get-job-stats-example]]
  245. ==== {api-examples-title}
  246. [source,console]
  247. --------------------------------------------------
  248. GET _ml/anomaly_detectors/low_request_rate/_stats
  249. --------------------------------------------------
  250. // TEST[skip:Kibana sample data]
  251. The API returns the following results:
  252. [source,js]
  253. ----
  254. {
  255. "count" : 1,
  256. "jobs" : [
  257. {
  258. "job_id" : "low_request_rate",
  259. "data_counts" : {
  260. "job_id" : "low_request_rate",
  261. "processed_record_count" : 1216,
  262. "processed_field_count" : 1216,
  263. "input_bytes" : 51678,
  264. "input_field_count" : 1216,
  265. "invalid_date_count" : 0,
  266. "missing_field_count" : 0,
  267. "out_of_order_timestamp_count" : 0,
  268. "empty_bucket_count" : 242,
  269. "sparse_bucket_count" : 0,
  270. "bucket_count" : 1457,
  271. "earliest_record_timestamp" : 1575172659612,
  272. "latest_record_timestamp" : 1580417369440,
  273. "last_data_time" : 1576017595046,
  274. "latest_empty_bucket_timestamp" : 1580356800000,
  275. "input_record_count" : 1216
  276. },
  277. "model_size_stats" : {
  278. "job_id" : "low_request_rate",
  279. "result_type" : "model_size_stats",
  280. "model_bytes" : 41480,
  281. "model_bytes_exceeded" : 0,
  282. "model_bytes_memory_limit" : 10485760,
  283. "total_by_field_count" : 3,
  284. "total_over_field_count" : 0,
  285. "total_partition_field_count" : 2,
  286. "bucket_allocation_failures_count" : 0,
  287. "memory_status" : "ok",
  288. "categorized_doc_count" : 0,
  289. "total_category_count" : 0,
  290. "frequent_category_count" : 0,
  291. "rare_category_count" : 0,
  292. "dead_category_count" : 0,
  293. "categorization_status" : "ok",
  294. "log_time" : 1576017596000,
  295. "timestamp" : 1580410800000
  296. },
  297. "forecasts_stats" : {
  298. "total" : 1,
  299. "forecasted_jobs" : 1,
  300. "memory_bytes" : {
  301. "total" : 9179.0,
  302. "min" : 9179.0,
  303. "avg" : 9179.0,
  304. "max" : 9179.0
  305. },
  306. "records" : {
  307. "total" : 168.0,
  308. "min" : 168.0,
  309. "avg" : 168.0,
  310. "max" : 168.0
  311. },
  312. "processing_time_ms" : {
  313. "total" : 40.0,
  314. "min" : 40.0,
  315. "avg" : 40.0,
  316. "max" : 40.0
  317. },
  318. "status" : {
  319. "finished" : 1
  320. }
  321. },
  322. "state" : "opened",
  323. "node" : {
  324. "id" : "7bmMXyWCRs-TuPfGJJ_yMw",
  325. "name" : "node-0",
  326. "ephemeral_id" : "hoXMLZB0RWKfR9UPPUCxXX",
  327. "transport_address" : "127.0.0.1:9300",
  328. "attributes" : {
  329. "ml.machine_memory" : "17179869184",
  330. "xpack.installed" : "true",
  331. "ml.max_open_jobs" : "20"
  332. }
  333. },
  334. "assignment_explanation" : "",
  335. "open_time" : "13s",
  336. "timing_stats" : {
  337. "job_id" : "low_request_rate",
  338. "bucket_count" : 1457,
  339. "total_bucket_processing_time_ms" : 1094.000000000001,
  340. "minimum_bucket_processing_time_ms" : 0.0,
  341. "maximum_bucket_processing_time_ms" : 48.0,
  342. "average_bucket_processing_time_ms" : 0.75085792724777,
  343. "exponential_average_bucket_processing_time_ms" : 0.5571716855800993,
  344. "exponential_average_bucket_processing_time_per_hour_ms" : 15.0
  345. }
  346. }
  347. ]
  348. }
  349. ----