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

# Get anomaly detection job model snapshot upgrade usage info

Availability: 7.16+

## Paths

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

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `job_id` (string Id)
  Identifier for the anomaly detection job.
- `snapshot_id` (string Id)
  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.

## Description



## Required authorization

* Cluster privileges: `monitor_ml`

## Query String Parameters

- `allow_no_match` (boolean)
  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` ([] ModelSnapshotUpgrade)
  - `job_id` (string Id)
  - `snapshot_id` (string Id)
  - `state` (enum SnapshotUpgradeState)
    Values: `loading_old_state`, `saving_new_state`, `stopped`, `failed`
  - `node` (DiscoveryNode)
  - `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"
)
```

