get-job-stats.asciidoc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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) For open jobs only, contains messages relating to the selection
  43. of a node to run the job.
  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) The number of bucket results produced by the job.
  51. `data_counts`.`earliest_record_timestamp`:::
  52. (date) The timestamp of the earliest chronologically input document.
  53. `data_counts`.`empty_bucket_count`:::
  54. (long) The number of buckets which did not contain any data. If your data
  55. contains many empty buckets, consider increasing your `bucket_span` or using
  56. functions that are tolerant to gaps in data such as `mean`, `non_null_sum` or
  57. `non_zero_count`.
  58. `data_counts`.`input_bytes`:::
  59. (long) The number of bytes of input data posted to the job.
  60. `data_counts`.`input_field_count`:::
  61. (long) The total number of fields in input documents posted to the job. This
  62. count includes fields that are not used in the analysis. However, be aware that
  63. if you are using a {dfeed}, it extracts only the required fields from the
  64. documents it retrieves before posting them to the job.
  65. `data_counts`.`input_record_count`:::
  66. (long) The number of input documents posted to the job.
  67. `data_counts`.`invalid_date_count`:::
  68. (long) The number of input documents with either a missing date field or a date
  69. that could not be parsed.
  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) The timestamp at which data was last analyzed, according to server time.
  75. `data_counts`.`latest_empty_bucket_timestamp`:::
  76. (date) The timestamp of the last bucket that did not contain any data.
  77. `data_counts`.`latest_record_timestamp`:::
  78. (date) The timestamp of the latest chronologically input document.
  79. `data_counts`.`latest_sparse_bucket_timestamp`:::
  80. (date) The timestamp of the last bucket that was considered sparse.
  81. `data_counts`.`missing_field_count`:::
  82. (long) The number of input documents that are missing a field that the job is
  83. configured to analyze. Input documents with missing fields are still processed
  84. because it is possible that not all fields are missing. The value of
  85. `processed_record_count` includes this count.
  86. +
  87. --
  88. NOTE: If you are using {dfeeds} or posting data to the job in JSON format, a
  89. high `missing_field_count` is often not an indication of data issues. It is not
  90. necessarily a cause for concern.
  91. --
  92. `data_counts`.`out_of_order_timestamp_count`:::
  93. (long) The number of input documents that are out of time sequence and outside
  94. of the latency window. This information is applicable only when you provide data
  95. to the job by using the <<ml-post-data,post data API>>. These out of order
  96. documents are discarded, since jobs require time series data to be in ascending
  97. chronological order.
  98. `data_counts`.`processed_field_count`:::
  99. (long) The total number of fields in all the documents that have been processed
  100. by the job. Only fields that are specified in the detector configuration object
  101. contribute to this count. The timestamp is not included in this count.
  102. `data_counts`.`processed_record_count`:::
  103. (long) The number of input documents that have been processed by the job. This
  104. value includes documents with missing fields, since they are nonetheless
  105. analyzed. If you use {dfeeds} and have aggregations in your search query, the
  106. `processed_record_count` will be the number of aggregation results processed,
  107. not the number of {es} documents.
  108. `data_counts`.`sparse_bucket_count`:::
  109. (long) The number of buckets that contained few data points compared to the
  110. expected number of data points. If your data contains many sparse buckets,
  111. consider using a longer `bucket_span`.
  112. [[forecastsstats]]`forecasts_stats`::
  113. (object) An object that provides statistical information about forecasts
  114. belonging to this job. Some statistics are omitted if no forecasts have been
  115. made. It has the following properties:
  116. +
  117. --
  118. NOTE: Unless there is at least one forecast, `memory_bytes`, `records`,
  119. `processing_time_ms` and `status` properties are omitted.
  120. --
  121. `forecasts_stats`.`forecasted_jobs`:::
  122. (long) A value of `0` indicates that forecasts do not exist for this job. A
  123. value of `1` indicates that at least one forecast exists.
  124. `forecasts_stats`.`memory_bytes`:::
  125. (object) The `avg`, `min`, `max` and `total` memory usage in bytes for forecasts
  126. related to this job. If there are no forecasts, this property is omitted.
  127. `forecasts_stats`.`records`:::
  128. (object) The `avg`, `min`, `max` and `total` number of model_forecast documents
  129. written for forecasts related to this job. If there are no forecasts, this property is omitted.
  130. `forecasts_stats`.`processing_time_ms`:::
  131. (object) The `avg`, `min`, `max` and `total` runtime in milliseconds for
  132. forecasts related to this job. If there are no forecasts, this property is omitted.
  133. `forecasts_stats`.`status`:::
  134. (object) The count of forecasts by their status. For example:
  135. {"finished" : 2, "started" : 1}. If there are no forecasts, this property is omitted.
  136. `forecasts_stats`.`total`:::
  137. (long) The number of individual forecasts currently available for this job. A
  138. value of `1` or more indicates that forecasts exist.
  139. `job_id`::
  140. (string)
  141. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  142. [[modelsizestats]]`model_size_stats`::
  143. (object) An object that provides information about the size and contents of the
  144. model. It has the following properties:
  145. `model_size_stats`.`bucket_allocation_failures_count`:::
  146. (long) The number of buckets for which new entities in incoming data were not
  147. processed due to insufficient model memory. This situation is also signified
  148. by a `hard_limit: memory_status` property value.
  149. `model_size_stats`.`job_id`:::
  150. (string)
  151. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  152. `model_size_stats`.`log_time`:::
  153. (date) The timestamp of the `model_size_stats` according to server time.
  154. `model_size_stats`.`memory_status`:::
  155. (string) The status of the mathematical models. This property can have one of
  156. the following values:
  157. +
  158. --
  159. * `ok`: The models stayed below the configured value.
  160. * `soft_limit`: The models used more than 60% of the configured memory limit
  161. and older unused models will be pruned to free up space.
  162. * `hard_limit`: The models used more space than the configured memory limit.
  163. As a result, not all incoming data was processed.
  164. --
  165. `model_size_stats`.`model_bytes`:::
  166. (long) The number of bytes of memory used by the models. This is the maximum
  167. value since the last time the model was persisted. If the job is closed,
  168. this value indicates the latest size.
  169. `model_size_stats`.`model_bytes_exceeded`:::
  170. (long) The number of bytes over the high limit for memory usage at the last
  171. allocation failure.
  172. `model_size_stats`.`model_bytes_memory_limit`:::
  173. (long) The upper limit for memory usage, checked on increasing values.
  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) The number of `by` field values that were analyzed by the models. This
  178. value is cumulative for all detectors.
  179. `model_size_stats`.`total_over_field_count`:::
  180. (long) The number of `over` field values that were analyzed by the models. This
  181. value is cumulative for all detectors.
  182. `model_size_stats`.`total_partition_field_count`:::
  183. (long) The number of `partition` field values that were analyzed by the models.
  184. This value is cumulative for all detectors.
  185. `model_size_stats`.`timestamp`:::
  186. (date) The timestamp of the `model_size_stats` according to the timestamp of the
  187. data.
  188. [[stats-node]]`node`::
  189. (object) Contains properties for the node that runs the job. This information is
  190. available only for open jobs.
  191. `node`.`attributes`:::
  192. (object) Lists node attributes. For example,
  193. `{"ml.machine_memory": "17179869184", "ml.max_open_jobs" : "20"}`.
  194. `node`.`ephemeral_id`:::
  195. (string) The ephemeral ID of the node.
  196. `node`.`id`:::
  197. (string) The unique identifier of the node.
  198. `node`.`name`:::
  199. (string) The node name.
  200. `node`.`transport_address`:::
  201. (string) The host and port where transport HTTP connections are accepted.
  202. `open_time`::
  203. (string) For open jobs only, the elapsed time for which the job has been open.
  204. For example, `28746386s`.
  205. `state`::
  206. (string) The status of the job, which can be one of the following values:
  207. +
  208. --
  209. * `closed`: The job finished successfully with its model state persisted. The
  210. job must be opened before it can accept further data.
  211. * `closing`: The job close action is in progress and has not yet completed. A
  212. closing job cannot accept further data.
  213. * `failed`: The job did not finish successfully due to an error. This situation
  214. can occur due to invalid input data, a fatal error occurring during the analysis,
  215. or an external interaction such as the process being killed by the Linux out of
  216. memory (OOM) killer. If the job had irrevocably failed, it must be force closed
  217. and then deleted. If the {dfeed} can be corrected, the job can be closed and
  218. then re-opened.
  219. * `opened`: The job is available to receive and process data.
  220. * `opening`: The job open action is in progress and has not yet completed.
  221. --
  222. [[timingstats]]`timing_stats`::
  223. (object) An object that provides statistical information about timing aspect of
  224. this job. It has the following properties:
  225. `timing_stats`.`average_bucket_processing_time_ms`:::
  226. (double) Average of all bucket processing times in milliseconds.
  227. `timing_stats`.`bucket_count`:::
  228. (long) The number of buckets processed.
  229. `timing_stats`.`exponential_average_bucket_processing_time_ms`:::
  230. (double) Exponential moving average of all bucket processing times in
  231. milliseconds.
  232. `timing_stats`.`exponential_average_bucket_processing_time_per_hour_ms`:::
  233. (double) Exponentially-weighted moving average of bucket processing times
  234. calculated in a 1 hour time window.
  235. `timing_stats`.`job_id`:::
  236. (string)
  237. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  238. `timing_stats`.`maximum_bucket_processing_time_ms`:::
  239. (double) Maximum among all bucket processing times in milliseconds.
  240. `timing_stats`.`minimum_bucket_processing_time_ms`:::
  241. (double) Minimum among all bucket processing times in milliseconds.
  242. `timing_stats`.`total_bucket_processing_time_ms`:::
  243. (double) Sum of all bucket processing times in milliseconds.
  244. [[ml-get-job-stats-response-codes]]
  245. ==== {api-response-codes-title}
  246. `404` (Missing resources)::
  247. If `allow_no_jobs` is `false`, this code indicates that there are no
  248. resources that match the request or only partial matches for the request.
  249. [[ml-get-job-stats-example]]
  250. ==== {api-examples-title}
  251. [source,console]
  252. --------------------------------------------------
  253. GET _ml/anomaly_detectors/low_request_rate/_stats
  254. --------------------------------------------------
  255. // TEST[skip:Kibana sample data]
  256. The API returns the following results:
  257. [source,js]
  258. ----
  259. {
  260. "count" : 1,
  261. "jobs" : [
  262. {
  263. "job_id" : "low_request_rate",
  264. "data_counts" : {
  265. "job_id" : "low_request_rate",
  266. "processed_record_count" : 1216,
  267. "processed_field_count" : 1216,
  268. "input_bytes" : 51678,
  269. "input_field_count" : 1216,
  270. "invalid_date_count" : 0,
  271. "missing_field_count" : 0,
  272. "out_of_order_timestamp_count" : 0,
  273. "empty_bucket_count" : 242,
  274. "sparse_bucket_count" : 0,
  275. "bucket_count" : 1457,
  276. "earliest_record_timestamp" : 1575172659612,
  277. "latest_record_timestamp" : 1580417369440,
  278. "last_data_time" : 1576017595046,
  279. "latest_empty_bucket_timestamp" : 1580356800000,
  280. "input_record_count" : 1216
  281. },
  282. "model_size_stats" : {
  283. "job_id" : "low_request_rate",
  284. "result_type" : "model_size_stats",
  285. "model_bytes" : 41480,
  286. "model_bytes_exceeded" : 0,
  287. "model_bytes_memory_limit" : 10485760,
  288. "total_by_field_count" : 3,
  289. "total_over_field_count" : 0,
  290. "total_partition_field_count" : 2,
  291. "bucket_allocation_failures_count" : 0,
  292. "memory_status" : "ok",
  293. "log_time" : 1576017596000,
  294. "timestamp" : 1580410800000
  295. },
  296. "forecasts_stats" : {
  297. "total" : 1,
  298. "forecasted_jobs" : 1,
  299. "memory_bytes" : {
  300. "total" : 9179.0,
  301. "min" : 9179.0,
  302. "avg" : 9179.0,
  303. "max" : 9179.0
  304. },
  305. "records" : {
  306. "total" : 168.0,
  307. "min" : 168.0,
  308. "avg" : 168.0,
  309. "max" : 168.0
  310. },
  311. "processing_time_ms" : {
  312. "total" : 40.0,
  313. "min" : 40.0,
  314. "avg" : 40.0,
  315. "max" : 40.0
  316. },
  317. "status" : {
  318. "finished" : 1
  319. }
  320. },
  321. "state" : "opened",
  322. "node" : {
  323. "id" : "7bmMXyWCRs-TuPfGJJ_yMw",
  324. "name" : "node-0",
  325. "ephemeral_id" : "hoXMLZB0RWKfR9UPPUCxXX",
  326. "transport_address" : "127.0.0.1:9300",
  327. "attributes" : {
  328. "ml.machine_memory" : "17179869184",
  329. "xpack.installed" : "true",
  330. "ml.max_open_jobs" : "20"
  331. }
  332. },
  333. "assignment_explanation" : "",
  334. "open_time" : "13s",
  335. "timing_stats" : {
  336. "job_id" : "low_request_rate",
  337. "bucket_count" : 1457,
  338. "total_bucket_processing_time_ms" : 1094.000000000001,
  339. "minimum_bucket_processing_time_ms" : 0.0,
  340. "maximum_bucket_processing_time_ms" : 48.0,
  341. "average_bucket_processing_time_ms" : 0.75085792724777,
  342. "exponential_average_bucket_processing_time_ms" : 0.5571716855800993,
  343. "exponential_average_bucket_processing_time_per_hour_ms" : 15.0
  344. }
  345. }
  346. ]
  347. }
  348. ----