get-trained-models-stats.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. [role="xpack"]
  2. [[get-trained-models-stats]]
  3. = Get trained models statistics API
  4. [subs="attributes"]
  5. ++++
  6. <titleabbrev>Get trained models stats</titleabbrev>
  7. ++++
  8. Retrieves usage information for trained models.
  9. [[ml-get-trained-models-stats-request]]
  10. == {api-request-title}
  11. `GET _ml/trained_models/_stats` +
  12. `GET _ml/trained_models/_all/_stats` +
  13. `GET _ml/trained_models/<model_id_or_deployment_id>/_stats` +
  14. `GET _ml/trained_models/<model_id_or_deployment_id>,<model_id_2_or_deployment_id_2>/_stats` +
  15. `GET _ml/trained_models/<model_id_pattern*_or_deployment_id_pattern*>,<model_id_2_or_deployment_id_2>/_stats`
  16. [[ml-get-trained-models-stats-prereq]]
  17. == {api-prereq-title}
  18. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  19. `machine_learning_user` built-in role.
  20. [[ml-get-trained-models-stats-desc]]
  21. == {api-description-title}
  22. You can get usage information for multiple trained models or trained model
  23. deployments in a single API request by using a comma-separated list of model
  24. IDs, deployment IDs, or a wildcard expression.
  25. [[ml-get-trained-models-stats-path-params]]
  26. == {api-path-parms-title}
  27. `<model_id_or_deployment_id>`::
  28. (Optional, string)
  29. The unique identifier of the model or the deployment. If a model has multiple
  30. deployments, and the ID of one of the deployments matches the model ID, then the
  31. model ID takes precedence; the results are returned for all deployments of the
  32. model.
  33. [[ml-get-trained-models-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-models]
  38. `from`::
  39. (Optional, integer)
  40. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
  41. `size`::
  42. (Optional, integer)
  43. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
  44. [role="child_attributes"]
  45. [[ml-get-trained-models-stats-results]]
  46. == {api-response-body-title}
  47. `count`::
  48. (integer)
  49. The total number of trained model statistics that matched the requested ID
  50. patterns. Could be higher than the number of items in the `trained_model_stats`
  51. array as the 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
  55. in ascending order.
  56. +
  57. .Properties of trained model stats
  58. [%collapsible%open]
  59. ====
  60. `deployment_stats`:::
  61. (list)
  62. A collection of deployment stats if one of the provided `model_id` values
  63. is deployed
  64. +
  65. .Properties of deployment stats
  66. [%collapsible%open]
  67. =====
  68. `allocation_status`:::
  69. (object)
  70. The detailed allocation status given the deployment configuration.
  71. +
  72. .Properties of allocation stats
  73. [%collapsible%open]
  74. ======
  75. `allocation_count`:::
  76. (integer)
  77. The current number of nodes where the model is allocated.
  78. `cache_size`:::
  79. (<<byte-units,byte value>>)
  80. The inference cache size (in memory outside the JVM heap) per node for the model.
  81. `state`:::
  82. (string)
  83. The detailed allocation state related to the nodes.
  84. +
  85. --
  86. * `starting`: Allocations are being attempted but no node currently has the model allocated.
  87. * `started`: At least one node has the model allocated.
  88. * `fully_allocated`: The deployment is fully allocated and satisfies the `target_allocation_count`.
  89. --
  90. `target_allocation_count`:::
  91. (integer)
  92. The desired number of nodes for model allocation.
  93. ======
  94. `deployment_id`:::
  95. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=deployment-id]
  96. `error_count`:::
  97. (integer)
  98. The sum of `error_count` for all nodes in the deployment.
  99. `inference_count`:::
  100. (integer)
  101. The sum of `inference_count` for all nodes in the deployment.
  102. `model_id`:::
  103. (string)
  104. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  105. `nodes`:::
  106. (array of objects)
  107. The deployment stats for each node that currently has the model allocated.
  108. +
  109. .Properties of node stats
  110. [%collapsible%open]
  111. ======
  112. `average_inference_time_ms`:::
  113. (double)
  114. The average time for each inference call to complete on this node.
  115. The average is calculated over the lifetime of the deployment.
  116. `average_inference_time_ms_excluding_cache_hits`:::
  117. (double)
  118. The average time to perform inference on the trained model excluding
  119. occasions where the response comes from the cache. Cached inference
  120. calls return very quickly as the model is not evaluated, by excluding
  121. cache hits this value is an accurate measure of the average time taken
  122. to evaluate the model.
  123. `average_inference_time_ms_last_minute`:::
  124. (double)
  125. The average time for each inference call to complete on this node
  126. in the last minute.
  127. `error_count`:::
  128. (integer)
  129. The number of errors when evaluating the trained model.
  130. `inference_cache_hit_count`:::
  131. (integer)
  132. The total number of inference calls made against this node for this
  133. model that were served from the inference cache.
  134. `inference_cache_hit_count_last_minute`:::
  135. (integer)
  136. The number of inference calls made against this node for this model
  137. in the last minute that were served from the inference cache.
  138. `inference_count`:::
  139. (integer)
  140. The total number of inference calls made against this node for this model.
  141. `last_access`:::
  142. (long)
  143. The epoch time stamp of the last inference call for the model on this node.
  144. `node`:::
  145. (object)
  146. Information pertaining to the node.
  147. +
  148. .Properties of node
  149. [%collapsible%open]
  150. ========
  151. `attributes`:::
  152. (object)
  153. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=node-attributes]
  154. `ephemeral_id`:::
  155. (string)
  156. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=node-ephemeral-id]
  157. `id`:::
  158. (string)
  159. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=node-id]
  160. `name`:::
  161. (string) The node name.
  162. `transport_address`:::
  163. (string)
  164. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=node-transport-address]
  165. ========
  166. `number_of_allocations`:::
  167. (integer)
  168. The number of allocations assigned to this node.
  169. `number_of_pending_requests`:::
  170. (integer)
  171. The number of inference requests queued to be processed.
  172. `peak_throughput_per_minute`:::
  173. (integer)
  174. The peak number of requests processed in a 1 minute period.
  175. `routing_state`:::
  176. (object)
  177. The current routing state and reason for the current routing state for this allocation.
  178. +
  179. .Properties of routing_state
  180. [%collapsible%open]
  181. ========
  182. `reason`:::
  183. (string)
  184. The reason for the current state. Usually only populated when the `routing_state` is `failed`.
  185. `routing_state`:::
  186. (string)
  187. The current routing state.
  188. --
  189. * `starting`: The model is attempting to allocate on this model, inference calls are not yet accepted.
  190. * `started`: The model is allocated and ready to accept inference requests.
  191. * `stopping`: The model is being deallocated from this node.
  192. * `stopped`: The model is fully deallocated from this node.
  193. * `failed`: The allocation attempt failed, see `reason` field for the potential cause.
  194. --
  195. ========
  196. `rejected_execution_count`:::
  197. (integer)
  198. The number of inference requests that were not processed because the
  199. queue was full.
  200. `start_time`:::
  201. (long)
  202. The epoch timestamp when the allocation started.
  203. `threads_per_allocation`:::
  204. (integer)
  205. The number of threads for each allocation during inference.
  206. This value is limited by the number of hardware threads on the node;
  207. it might therefore differ from the `threads_per_allocation` value in the <<start-trained-model-deployment>> API.
  208. `timeout_count`:::
  209. (integer)
  210. The number of inference requests that timed out before being processed.
  211. `throughput_last_minute`:::
  212. (integer)
  213. The number of requests processed in the last 1 minute.
  214. ======
  215. `number_of_allocations`:::
  216. (integer)
  217. The requested number of allocations for the trained model deployment.
  218. `peak_throughput_per_minute`:::
  219. (integer)
  220. The peak number of requests processed in a 1 minute period for
  221. all nodes in the deployment. This is calculated as the sum of
  222. each node's `peak_throughput_per_minute` value.
  223. `priority`:::
  224. (string)
  225. The deployment priority.
  226. `rejected_execution_count`:::
  227. (integer)
  228. The sum of `rejected_execution_count` for all nodes in the deployment.
  229. Individual nodes reject an inference request if the inference queue is full.
  230. The queue size is controlled by the `queue_capacity` setting in the
  231. <<start-trained-model-deployment>> API.
  232. `reason`:::
  233. (string)
  234. The reason for the current deployment state.
  235. Usually only populated when the model is not deployed to a node.
  236. `start_time`:::
  237. (long)
  238. The epoch timestamp when the deployment started.
  239. `state`:::
  240. (string)
  241. The overall state of the deployment. The values may be:
  242. +
  243. --
  244. * `starting`: The deployment has recently started but is not yet usable as the model is not allocated on any nodes.
  245. * `started`: The deployment is usable as at least one node has the model allocated.
  246. * `stopping`: The deployment is preparing to stop and deallocate the model from the relevant nodes.
  247. --
  248. `threads_per_allocation`:::
  249. (integer)
  250. The number of threads per allocation used by the inference process.
  251. `timeout_count`:::
  252. (integer)
  253. The sum of `timeout_count` for all nodes in the deployment.
  254. `queue_capacity`:::
  255. (integer)
  256. The number of inference requests that may be queued before new requests are
  257. rejected.
  258. =====
  259. `inference_stats`:::
  260. (object)
  261. A collection of inference stats fields.
  262. +
  263. .Properties of inference stats
  264. [%collapsible%open]
  265. =====
  266. `missing_all_fields_count`:::
  267. (integer)
  268. The number of inference calls where all the training features for the model
  269. were missing.
  270. `inference_count`:::
  271. (integer)
  272. The total number of times the model has been called for inference.
  273. This is across all inference contexts, including all pipelines.
  274. `cache_miss_count`:::
  275. (integer)
  276. The number of times the model was loaded for inference and was not retrieved
  277. from the cache. If this number is close to the `inference_count`, then the cache
  278. is not being appropriately used. This can be solved by increasing the cache size
  279. or its time-to-live (TTL). See <<general-ml-settings>> for the appropriate
  280. settings.
  281. `failure_count`:::
  282. (integer)
  283. The number of failures when using the model for inference.
  284. `timestamp`:::
  285. (<<time-units,time units>>)
  286. The time when the statistics were last updated.
  287. =====
  288. `ingest`:::
  289. (object)
  290. A collection of ingest stats for the model across all nodes. The values are
  291. summations of the individual node statistics. The format matches the `ingest`
  292. section in <<cluster-nodes-stats>>.
  293. `model_id`:::
  294. (string)
  295. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  296. `model_size_stats`:::
  297. (object)
  298. A collection of model size stats fields.
  299. +
  300. .Properties of model size stats
  301. [%collapsible%open]
  302. =====
  303. `model_size_bytes`:::
  304. (integer)
  305. The size of the model in bytes.
  306. `required_native_memory_bytes`:::
  307. (integer)
  308. The amount of memory required to load the model in bytes.
  309. =====
  310. `pipeline_count`:::
  311. (integer)
  312. The number of ingest pipelines that currently refer to the model.
  313. ====
  314. [[ml-get-trained-models-stats-response-codes]]
  315. == {api-response-codes-title}
  316. `404` (Missing resources)::
  317. If `allow_no_match` is `false`, this code indicates that there are no
  318. resources that match the request or only partial matches for the request.
  319. [[ml-get-trained-models-stats-example]]
  320. == {api-examples-title}
  321. The following example gets usage information for all the trained models:
  322. [source,console]
  323. --------------------------------------------------
  324. GET _ml/trained_models/_stats
  325. --------------------------------------------------
  326. // TEST[skip:TBD]
  327. The API returns the following results:
  328. [source,console-result]
  329. ----
  330. {
  331. "count": 2,
  332. "trained_model_stats": [
  333. {
  334. "model_id": "flight-delay-prediction-1574775339910",
  335. "pipeline_count": 0,
  336. "inference_stats": {
  337. "failure_count": 0,
  338. "inference_count": 4,
  339. "cache_miss_count": 3,
  340. "missing_all_fields_count": 0,
  341. "timestamp": 1592399986979
  342. }
  343. },
  344. {
  345. "model_id": "regression-job-one-1574775307356",
  346. "pipeline_count": 1,
  347. "inference_stats": {
  348. "failure_count": 0,
  349. "inference_count": 178,
  350. "cache_miss_count": 3,
  351. "missing_all_fields_count": 0,
  352. "timestamp": 1592399986979
  353. },
  354. "ingest": {
  355. "total": {
  356. "count": 178,
  357. "time_in_millis": 8,
  358. "current": 0,
  359. "failed": 0
  360. },
  361. "pipelines": {
  362. "flight-delay": {
  363. "count": 178,
  364. "time_in_millis": 8,
  365. "current": 0,
  366. "failed": 0,
  367. "processors": [
  368. {
  369. "inference": {
  370. "type": "inference",
  371. "stats": {
  372. "count": 178,
  373. "time_in_millis": 7,
  374. "current": 0,
  375. "failed": 0
  376. }
  377. }
  378. }
  379. ]
  380. }
  381. }
  382. }
  383. }
  384. ]
  385. }
  386. ----
  387. // NOTCONSOLE