get-inference-trained-model-stats.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[get-inference-stats]]
  4. = Get {infer} trained model statistics API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Get {infer} trained model stats</titleabbrev>
  8. ++++
  9. Retrieves usage information for trained {infer} models.
  10. experimental[]
  11. [[ml-get-inference-stats-request]]
  12. == {api-request-title}
  13. `GET _ml/inference/_stats` +
  14. `GET _ml/inference/_all/_stats` +
  15. `GET _ml/inference/<model_id>/_stats` +
  16. `GET _ml/inference/<model_id>,<model_id_2>/_stats` +
  17. `GET _ml/inference/<model_id_pattern*>,<model_id_2>/_stats`
  18. [[ml-get-inference-stats-prereq]]
  19. == {api-prereq-title}
  20. If the {es} {security-features} are enabled, you must have the following
  21. privileges:
  22. * cluster: `monitor_ml`
  23. For more information, see <<security-privileges>> and {ml-docs-setup-privileges}.
  24. [[ml-get-inference-stats-desc]]
  25. == {api-description-title}
  26. You can get usage information for multiple trained models in a single API
  27. request by using a comma-separated list of model IDs or a wildcard expression.
  28. [[ml-get-inference-stats-path-params]]
  29. == {api-path-parms-title}
  30. `<model_id>`::
  31. (Optional, string)
  32. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  33. [[ml-get-inference-stats-query-params]]
  34. == {api-query-parms-title}
  35. `allow_no_match`::
  36. (Optional, boolean)
  37. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match]
  38. `from`::
  39. (Optional, integer)
  40. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from]
  41. `size`::
  42. (Optional, integer)
  43. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size]
  44. [role="child_attributes"]
  45. [[ml-get-inference-stats-results]]
  46. == {api-response-body-title}
  47. `count`::
  48. (integer)
  49. The total number of trained model statistics that matched the requested ID patterns.
  50. Could be higher than the number of items in the `trained_model_stats` array as the
  51. size of the array is restricted by the supplied `size` parameter.
  52. `trained_model_stats`::
  53. (array)
  54. An array of trained model statistics, which are sorted by the `model_id` value in
  55. ascending order.
  56. +
  57. .Properties of trained model stats
  58. [%collapsible%open]
  59. ====
  60. `model_id`:::
  61. (string)
  62. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  63. `pipeline_count`:::
  64. (integer)
  65. The number of ingest pipelines that currently refer to the model.
  66. `inference_stats`:::
  67. (object)
  68. A collection of inference stats fields.
  69. +
  70. .Properties of inference stats
  71. [%collapsible%open]
  72. =====
  73. `missing_all_fields_count`:::
  74. (integer)
  75. The number of inference calls where all the training features for the model
  76. were missing.
  77. `inference_count`:::
  78. (integer)
  79. The total number of times the model has been called for inference.
  80. This is across all inference contexts, including all pipelines.
  81. `cache_miss_count`:::
  82. (integer)
  83. The number of times the model was loaded for inference and was not retrieved from the
  84. cache. If this number is close to the `inference_count`, then the cache
  85. is not being appropriately used. This can be remedied by increasing the cache's size
  86. or its time-to-live (TTL). See <<general-ml-settings>> for the
  87. appropriate settings.
  88. `failure_count`:::
  89. (integer)
  90. The number of failures when using the model for inference.
  91. `timestamp`:::
  92. (<<time-units,time units>>)
  93. The time when the statistics were last updated.
  94. =====
  95. `ingest`:::
  96. (object)
  97. A collection of ingest stats for the model across all nodes. The values are
  98. summations of the individual node statistics. The format matches the `ingest`
  99. section in <<cluster-nodes-stats>>.
  100. ====
  101. [[ml-get-inference-stats-response-codes]]
  102. == {api-response-codes-title}
  103. `404` (Missing resources)::
  104. If `allow_no_match` is `false`, this code indicates that there are no
  105. resources that match the request or only partial matches for the request.
  106. [[ml-get-inference-stats-example]]
  107. == {api-examples-title}
  108. The following example gets usage information for all the trained models:
  109. [source,console]
  110. --------------------------------------------------
  111. GET _ml/inference/_stats
  112. --------------------------------------------------
  113. // TEST[skip:TBD]
  114. The API returns the following results:
  115. [source,console-result]
  116. ----
  117. {
  118. "count": 2,
  119. "trained_model_stats": [
  120. {
  121. "model_id": "flight-delay-prediction-1574775339910",
  122. "pipeline_count": 0,
  123. "inference_stats": {
  124. "failure_count": 0,
  125. "inference_count": 4,
  126. "cache_miss_count": 3,
  127. "missing_all_fields_count": 0,
  128. "timestamp": 1592399986979
  129. }
  130. },
  131. {
  132. "model_id": "regression-job-one-1574775307356",
  133. "pipeline_count": 1,
  134. "inference_stats": {
  135. "failure_count": 0,
  136. "inference_count": 178,
  137. "cache_miss_count": 3,
  138. "missing_all_fields_count": 0,
  139. "timestamp": 1592399986979
  140. },
  141. "ingest": {
  142. "total": {
  143. "count": 178,
  144. "time_in_millis": 8,
  145. "current": 0,
  146. "failed": 0
  147. },
  148. "pipelines": {
  149. "flight-delay": {
  150. "count": 178,
  151. "time_in_millis": 8,
  152. "current": 0,
  153. "failed": 0,
  154. "processors": [
  155. {
  156. "inference": {
  157. "type": "inference",
  158. "stats": {
  159. "count": 178,
  160. "time_in_millis": 7,
  161. "current": 0,
  162. "failed": 0
  163. }
  164. }
  165. }
  166. ]
  167. }
  168. }
  169. }
  170. }
  171. ]
  172. }
  173. ----
  174. // NOTCONSOLE