---
type: api
title: Get anomaly detection job model snapshot upgrade usage info
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/operation/operation-ml-get-model-snapshot-upgrade-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/operation/operation-ml-get-model-snapshot-upgrade-stats
products:
  - Elasticsearch
---

# Get anomaly detection job model snapshot upgrade usage info

Authentication: required

Availability: Generally available since 7.16

## Paths

- `GET` `/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_upgrade/_stats`

#### Path parameters

- `job_id` (string) — required
  Identifier for the anomaly detection job.
- `snapshot_id` (string) — required
  A numerical character string that uniquely identifies the model snapshot. You can get information for multiple
snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using `_all`,
by specifying `*` as the snapshot ID, or by omitting the snapshot ID.

## Required authorization

- Cluster privileges: `monitor_ml`

## Query string parameters

- `allow_no_match` (boolean) — optional
  Specifies what to do when the request:

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

The default value is true, which returns an empty jobs array when there are no matches and the subset of results
when there are partial matches. If this parameter is false, the request returns a 404 status code when there are
no matches or only partial matches.

## Response

`application/json`

- `count` (number)
- `model_snapshot_upgrades` (object[])
  - `job_id` (string)
  - `snapshot_id` (string)
  - `state` (enum)
    Values: `loading_old_state`, `saving_new_state`, `stopped`, `failed`
  - `node` (object)
  - `assignment_explanation` (string)
## Code examples

#### Console

```console
GET _ml/anomaly_detectors/low_request_rate/model_snapshots/_all/_upgrade/_stats
```

#### JavaScript

```javascript
const response = await client.ml.getModelSnapshotUpgradeStats({
  job_id: "low_request_rate",
  snapshot_id: "_all",
});
```

#### Python

```python
resp = client.ml.get_model_snapshot_upgrade_stats(
    job_id="low_request_rate",
    snapshot_id="_all",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/_all/_upgrade/_stats" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().getModelSnapshotUpgradeStats(g -> g
    .jobId("low_request_rate")
    .snapshotId("_all")
);
```

#### C#

```c#
var response = await client.MachineLearning.GetModelSnapshotUpgradeStatsAsync(jobId: "low_request_rate", snapshotId: "_all");
```

#### PHP

```php
$resp = $client->ml()->getModelSnapshotUpgradeStats([
    "job_id" => "low_request_rate",
    "snapshot_id" => "_all",
]);
```

#### Ruby

```ruby
response = client.ml.get_model_snapshot_upgrade_stats(
  job_id: "low_request_rate",
  snapshot_id: "_all"
)
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "count": 0,
  "model_snapshot_upgrades": [
    {
      "job_id": "string",
      "snapshot_id": "string",
      "state": "loading_old_state",
      "node": {
        "key": {
          "name": "string",
          "ephemeral_id": "string",
          "transport_address": "string",
          "external_id": "string",
          "attributes": {
            "key": "string"
          },
          "roles": [
            "string"
          ],
          "version": "string",
          "min_index_version": 0,
          "max_index_version": 0
        }
      },
      "assignment_explanation": "string"
    }
  ]
}
```

