|
| 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 | + |
| 10 | +Retrieves usage information for trained {infer} models. |
| 11 | + |
| 12 | +experimental[] |
| 13 | + |
| 14 | + |
| 15 | +[[ml-get-inference-stats-request]] |
| 16 | +==== {api-request-title} |
| 17 | + |
| 18 | +`GET _ml/inference/_stats` + |
| 19 | + |
| 20 | +`GET _ml/inference/_all/_stats` + |
| 21 | + |
| 22 | +`GET _ml/inference/<model_id>/_stats` + |
| 23 | + |
| 24 | +`GET _ml/inference/<model_id>,<model_id_2>/_stats` + |
| 25 | + |
| 26 | +`GET _ml/inference/<model_id_pattern*>,<model_id_2>/_stats` |
| 27 | + |
| 28 | + |
| 29 | +[[ml-get-inference-stats-prereq]] |
| 30 | +==== {api-prereq-title} |
| 31 | + |
| 32 | +* You must have `monitor_ml` privilege to use this API. For more information, |
| 33 | +see <<security-privileges>> and <<built-in-roles>>. |
| 34 | + |
| 35 | + |
| 36 | +[[ml-get-inference-stats-desc]] |
| 37 | +==== {api-description-title} |
| 38 | + |
| 39 | +You can get usage information for multiple trained models in a single API |
| 40 | +request by using a comma-separated list of model IDs or a wildcard expression. |
| 41 | + |
| 42 | + |
| 43 | +[[ml-get-inference-stats-path-params]] |
| 44 | +==== {api-path-parms-title} |
| 45 | + |
| 46 | +`<model_id>`:: |
| 47 | +(Optional, string) |
| 48 | +include::{docdir}/ml/ml-shared.asciidoc[tag=model-id] |
| 49 | + |
| 50 | + |
| 51 | +[[ml-get-inference-stats-query-params]] |
| 52 | +==== {api-query-parms-title} |
| 53 | + |
| 54 | +`allow_no_match`:: |
| 55 | +(Optional, boolean) |
| 56 | +include::{docdir}/ml/ml-shared.asciidoc[tag=allow-no-match] |
| 57 | + |
| 58 | +`from`:: |
| 59 | +(Optional, integer) |
| 60 | +include::{docdir}/ml/ml-shared.asciidoc[tag=from] |
| 61 | + |
| 62 | +`size`:: |
| 63 | +(Optional, integer) |
| 64 | +include::{docdir}/ml/ml-shared.asciidoc[tag=size] |
| 65 | + |
| 66 | + |
| 67 | +[[ml-get-inference-stats-response-codes]] |
| 68 | +==== {api-response-codes-title} |
| 69 | + |
| 70 | +`404` (Missing resources):: |
| 71 | + If `allow_no_match` is `false`, this code indicates that there are no |
| 72 | + resources that match the request or only partial matches for the request. |
| 73 | + |
| 74 | + |
| 75 | +[[ml-get-inference-stats-example]] |
| 76 | +==== {api-examples-title} |
| 77 | + |
| 78 | +The following example gets usage information for all the trained models: |
| 79 | + |
| 80 | +[source,console] |
| 81 | +-------------------------------------------------- |
| 82 | +GET _ml/inference/_stats |
| 83 | +-------------------------------------------------- |
| 84 | +// TEST[skip:TBD] |
| 85 | + |
| 86 | + |
| 87 | +The API returns the following results: |
| 88 | + |
| 89 | +[source,console-result] |
| 90 | +---- |
| 91 | +{ |
| 92 | + "count": 2, |
| 93 | + "trained_model_stats": [ |
| 94 | + { |
| 95 | + "model_id": "flight-delay-prediction-1574775339910", |
| 96 | + "pipeline_count": 0 |
| 97 | + }, |
| 98 | + { |
| 99 | + "model_id": "regression-job-one-1574775307356", |
| 100 | + "pipeline_count": 1, |
| 101 | + "ingest": { |
| 102 | + "total": { |
| 103 | + "count": 178, |
| 104 | + "time_in_millis": 8, |
| 105 | + "current": 0, |
| 106 | + "failed": 0 |
| 107 | + }, |
| 108 | + "pipelines": { |
| 109 | + "flight-delay": { |
| 110 | + "count": 178, |
| 111 | + "time_in_millis": 8, |
| 112 | + "current": 0, |
| 113 | + "failed": 0, |
| 114 | + "processors": [ |
| 115 | + { |
| 116 | + "inference": { |
| 117 | + "type": "inference", |
| 118 | + "stats": { |
| 119 | + "count": 178, |
| 120 | + "time_in_millis": 7, |
| 121 | + "current": 0, |
| 122 | + "failed": 0 |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + ] |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | + ] |
| 132 | +} |
| 133 | +---- |
| 134 | +// NOTCONSOLE |
0 commit comments