get-trained-models-stats.asciidoc 5.3 KB

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