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

# Get anomaly detection job model snapshot upgrade usage info

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`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## 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"
)
```

