get-job-stats.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. {stack-ov}/security-privileges.html[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) An identifier for the {anomaly-job}. It can be a
  31. job identifier, a group name, or a wildcard expression. If you do not specify
  32. one of these options, the API returns statistics for all {anomaly-jobs}.
  33. [[ml-get-job-stats-query-parms]]
  34. ==== {api-query-parms-title}
  35. `allow_no_jobs`::
  36. (Optional, boolean) Specifies what to do when the request:
  37. +
  38. --
  39. * Contains wildcard expressions and there are no jobs that match.
  40. * Contains the `_all` string or no identifiers and there are no matches.
  41. * Contains wildcard expressions and there are only partial matches.
  42. The default value is `true`, which returns an empty `jobs` array
  43. when there are no matches and the subset of results when there are partial
  44. matches. If this parameter is `false`, the request returns a `404` status code
  45. when there are no matches or only partial matches.
  46. --
  47. [[ml-get-job-stats-results]]
  48. ==== {api-response-body-title}
  49. The API returns the following information:
  50. `jobs`::
  51. (array) An array of {anomaly-job} statistics objects.
  52. For more information, see <<ml-jobstats>>.
  53. [[ml-get-job-stats-response-codes]]
  54. ==== {api-response-codes-title}
  55. `404` (Missing resources)::
  56. If `allow_no_jobs` is `false`, this code indicates that there are no
  57. resources that match the request or only partial matches for the request.
  58. [[ml-get-job-stats-example]]
  59. ==== {api-examples-title}
  60. The following example gets usage information for the `farequote` job:
  61. [source,js]
  62. --------------------------------------------------
  63. GET _ml/anomaly_detectors/farequote/_stats
  64. --------------------------------------------------
  65. // CONSOLE
  66. // TEST[skip:todo]
  67. The API returns the following results:
  68. [source,js]
  69. ----
  70. {
  71. "count": 1,
  72. "jobs": [
  73. {
  74. "job_id": "farequote",
  75. "data_counts": {
  76. "job_id": "farequote",
  77. "processed_record_count": 86275,
  78. "processed_field_count": 172550,
  79. "input_bytes": 6744714,
  80. "input_field_count": 172550,
  81. "invalid_date_count": 0,
  82. "missing_field_count": 0,
  83. "out_of_order_timestamp_count": 0,
  84. "empty_bucket_count": 0,
  85. "sparse_bucket_count": 15,
  86. "bucket_count": 1528,
  87. "earliest_record_timestamp": 1454803200000,
  88. "latest_record_timestamp": 1455235196000,
  89. "last_data_time": 1491948163685,
  90. "latest_sparse_bucket_timestamp": 1455174900000,
  91. "input_record_count": 86275
  92. },
  93. "model_size_stats": {
  94. "job_id": "farequote",
  95. "result_type": "model_size_stats",
  96. "model_bytes": 387594,
  97. "total_by_field_count": 21,
  98. "total_over_field_count": 0,
  99. "total_partition_field_count": 20,
  100. "bucket_allocation_failures_count": 0,
  101. "memory_status": "ok",
  102. "log_time": 1491948163000,
  103. "timestamp": 1455234600000
  104. },
  105. "state": "closed",
  106. "timing_stats": {
  107. "job_id": "farequote",
  108. "minimum_bucket_processing_time_ms": 0.0,
  109. "maximum_bucket_processing_time_ms": 15.0,
  110. "average_bucket_processing_time_ms": 8.75,
  111. "exponential_average_bucket_processing_time_ms": 6.1435899
  112. }
  113. }
  114. ]
  115. }
  116. ----