Get trained models usage info Added in 7.10.0

GET /_ml/trained_models/{model_id}/_stats

You can get usage information for multiple trained models in a single API request by using a comma-separated list of model IDs or a wildcard expression.

Path parameters

  • model_id string | array[string] Required

    The unique identifier of the trained model or a model alias. It can be a comma-separated list or a wildcard expression.

Query parameters

  • Specifies what to do when the request:

    • Contains wildcard expressions and there are no models that match.
    • Contains the _all string or no identifiers and there are no matches.
    • Contains wildcard expressions and there are only partial matches.

    If true, it returns an empty array when there are no matches and the subset of results when there are partial matches.

  • from number

    Skips the specified number of models.

  • size number

    Specifies the maximum number of models to obtain.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • count number Required

      The total number of trained model statistics that matched the requested ID patterns. Could be higher than the number of items in the trained_model_stats array as the size of the array is restricted by the supplied size parameter.

    • trained_model_stats array[object] Required

      An array of trained model statistics, which are sorted by the model_id value in ascending order.

      Hide trained_model_stats attributes Show trained_model_stats attributes object
      • Additional properties are allowed.

        Hide deployment_stats attributes Show deployment_stats attributes object
        • allocation_status object Required

          Additional properties are allowed.

          Hide allocation_status attributes Show allocation_status attributes object
          • allocation_count number Required

            The current number of nodes where the model is allocated.

          • state string Required

            Values are started, starting, or fully_allocated.

          • The desired number of nodes for model allocation.

        • deployment_id string Required
        • error_count number Required

          The sum of error_count for all nodes in the deployment.

        • inference_count number Required

          The sum of inference_count for all nodes in the deployment.

        • model_id string Required
        • nodes array[object] Required

          The deployment stats for each node that currently has the model allocated. In serverless, stats are reported for a single unnamed virtual node.

          Hide nodes attributes Show nodes attributes object
        • number_of_allocations number Required

          The number of allocations requested.

        • queue_capacity number Required

          The number of inference requests that can be queued before new requests are rejected.

        • The sum of rejected_execution_count for all nodes in the deployment. Individual nodes reject an inference request if the inference queue is full. The queue size is controlled by the queue_capacity setting in the start trained model deployment API.

        • reason string Required

          The reason for the current deployment state. Usually only populated when the model is not deployed to a node.

        • Time unit for milliseconds

        • state string Required

          Values are started, starting, stopping, or failed.

        • threads_per_allocation number Required

          The number of threads used be each allocation during inference.

        • timeout_count number Required

          The sum of timeout_count for all nodes in the deployment.

      • Additional properties are allowed.

        Hide inference_stats attributes Show inference_stats attributes object
        • cache_miss_count number Required

          The number of times the model was loaded for inference and was not retrieved from the cache. If this number is close to the inference_count, the cache is not being appropriately used. This can be solved by increasing the cache size or its time-to-live (TTL). Refer to general machine learning settings for the appropriate settings.

        • failure_count number Required

          The number of failures when using the model for inference.

        • inference_count number Required

          The total number of times the model has been called for inference. This is across all inference contexts, including all pipelines.

        • The number of inference calls where all the training features for the model were missing.

        • Time unit for milliseconds

      • ingest object

        A collection of ingest stats for the model across all nodes. The values are summations of the individual node statistics. The format matches the ingest section in the nodes stats API.

        Hide ingest attribute Show ingest attribute object
        • * object Additional properties

          Additional properties are allowed.

      • model_id string Required
      • model_size_stats object Required

        Additional properties are allowed.

        Hide model_size_stats attributes Show model_size_stats attributes object
      • pipeline_count number Required

        The number of ingest pipelines that currently refer to the model.

GET /_ml/trained_models/{model_id}/_stats
curl \
 -X GET http://api.example.com/_ml/trained_models/{model_id}/_stats
Response examples (200)
{
  "count": 42.0,
  "trained_model_stats": [
    {
      "deployment_stats": {
        "allocation_status": {
          "allocation_count": 42.0,
          "state": "started",
          "target_allocation_count": 42.0
        },
        "": 42.0,
        "deployment_id": "string",
        "error_count": 42.0,
        "inference_count": 42.0,
        "model_id": "string",
        "nodes": [
          {
            "error_count": 42.0,
            "inference_count": 42.0,
            "last_access": 42.0,
            "node": {},
            "number_of_allocations": 42.0,
            "number_of_pending_requests": 42.0,
            "rejection_execution_count": 42.0,
            "routing_state": {},
            "threads_per_allocation": 42.0,
            "timeout_count": 42.0
          }
        ],
        "number_of_allocations": 42.0,
        "queue_capacity": 42.0,
        "rejected_execution_count": 42.0,
        "reason": "string",
        "state": "started",
        "threads_per_allocation": 42.0,
        "timeout_count": 42.0
      },
      "inference_stats": {
        "cache_miss_count": 42.0,
        "failure_count": 42.0,
        "inference_count": 42.0,
        "missing_all_fields_count": 42.0,
        "": 42.0
      },
      "ingest": {
        "additionalProperty1": {},
        "additionalProperty2": {}
      },
      "model_id": "string",
      "model_size_stats": {
        "": 42.0
      },
      "pipeline_count": 42.0
    }
  ]
}