---
type: api
title: Get anomaly detection job stats
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-ml-get-job-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-ml-get-job-stats
products:
  - Elasticsearch Serverless
---

# Get anomaly detection job stats


Availability:

## Paths

- `GET` `/_ml/anomaly_detectors/{job_id}/_stats`
- `GET` `/_ml/anomaly_detectors/_stats`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `job_id` (string Id) — optional, leave it out to use `/_ml/anomaly_detectors/_stats`
  Identifier for the anomaly detection job. It can be a job identifier, a
group name, a comma-separated list of jobs, or a wildcard expression. If
you do not specify one of these options, the API returns information for
all anomaly detection jobs.

## Description

## Required authorization

* Cluster privileges: `monitor_ml`

## Query String Parameters

- `allow_no_match` (boolean · default: true)
  Specifies what to do when the request:

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

If `true`, the API returns an empty `jobs` array when
there are no matches and the subset of results when there are partial
matches. If `false`, the API returns a `404` status
code when there are no matches or only partial matches.

## Response

`application/json`

- `count` (number)
- `jobs` ([] JobStats)
  - `assignment_explanation` (string)
    For open anomaly detection jobs only, contains messages relating to the selection of a node to run the job.
  - `data_counts` ({} DataCounts)
    An object that describes the quantity of input to the job and any related error counts.
The `data_count` values are cumulative for the lifetime of a job.
If a model snapshot is reverted or old results are deleted, the job counts are not reset.
    - `bucket_count` (number)
    - `earliest_record_timestamp` (number)
    - `empty_bucket_count` (number)
    - `input_bytes` (number)
    - `input_field_count` (number)
    - `input_record_count` (number)
    - `invalid_date_count` (number)
    - `job_id` (string Id)
    - `last_data_time` (number)
    - `latest_empty_bucket_timestamp` (number)
    - `latest_record_timestamp` (number)
    - `latest_sparse_bucket_timestamp` (number)
    - `latest_bucket_timestamp` (number)
    - `log_time` (number)
    - `missing_field_count` (number)
    - `out_of_order_timestamp_count` (number)
    - `processed_field_count` (number)
    - `processed_record_count` (number)
    - `sparse_bucket_count` (number)
  - `forecasts_stats` ({} JobForecastStatistics)
    An object that provides statistical information about forecasts belonging to this job.
Some statistics are omitted if no forecasts have been made.
    - `memory_bytes` ({} JobStatistics)
      - `avg` (number)
      - `max` (number)
      - `min` (number)
      - `total` (number)
    - `processing_time_ms` ({} JobStatistics)
      - `avg` (number)
      - `max` (number)
      - `min` (number)
      - `total` (number)
    - `records` ({} JobStatistics)
      - `avg` (number)
      - `max` (number)
      - `min` (number)
      - `total` (number)
    - `status` (map string to number)
    - `total` (number)
    - `forecasted_jobs` (number)
  - `job_id` (string)
    Identifier for the anomaly detection job.
  - `model_size_stats` ({} ModelSizeStats)
    An object that provides information about the size and contents of the model.
    - `bucket_allocation_failures_count` (number)
    - `job_id` (string Id)
    - `log_time` (DateTime)
    - `memory_status` (enum MemoryStatus)
      Values: `ok`, `soft_limit`, `hard_limit`
    - `model_bytes` (number | string ByteSize)
    - `model_bytes_exceeded` (number | string ByteSize)
    - `model_bytes_memory_limit` (number | string ByteSize)
    - `output_memory_allocator_bytes` (number | string ByteSize)
    - `peak_model_bytes` (number | string ByteSize)
    - `assignment_memory_basis` (string)
    - `result_type` (string)
    - `total_by_field_count` (number)
    - `total_over_field_count` (number)
    - `total_partition_field_count` (number)
    - `categorization_status` (enum CategorizationStatus)
      Values: `ok`, `warn`
    - `categorized_doc_count` (number)
    - `dead_category_count` (number)
    - `failed_category_count` (number)
    - `frequent_category_count` (number)
    - `rare_category_count` (number)
    - `total_category_count` (number)
    - `timestamp` (number)
  - `open_time` (DateTime)
    For open jobs only, the elapsed time for which the job has been open.
  - `state` (enum JobState)
    The status of the anomaly detection job, which can be one of the following values: `closed`, `closing`, `failed`, `opened`, `opening`.

Supported values include:
  - `closing`: The job close action is in progress and has not yet completed. A closing job cannot accept further data.
  - `closed`: The job finished successfully with its model state persisted. The job must be opened before it can accept further data.
  - `opened`: The job is available to receive and process data.
  - `failed`: The job did not finish successfully due to an error.
This situation can occur due to invalid input data, a fatal error occurring during the analysis, or an external interaction such as the process being killed by the Linux out of memory (OOM) killer.
If the job had irrevocably failed, it must be force closed and then deleted.
If the datafeed can be corrected, the job can be closed and then re-opened.
  - `opening`: The job open action is in progress and has not yet completed.
    Values: `closing`, `closed`, `opened`, `failed`, `opening`
  - `timing_stats` ({} JobTimingStats)
    An object that provides statistical information about timing aspect of this job.
    - `average_bucket_processing_time_ms` (DurationValueUnitFloatMillis)
    - `bucket_count` (number)
    - `exponential_average_bucket_processing_time_ms` (DurationValueUnitFloatMillis)
    - `exponential_average_bucket_processing_time_per_hour_ms` (DurationValueUnitFloatMillis)
    - `job_id` (string Id)
    - `total_bucket_processing_time_ms` (DurationValueUnitFloatMillis)
    - `maximum_bucket_processing_time_ms` (DurationValueUnitFloatMillis)
    - `minimum_bucket_processing_time_ms` (DurationValueUnitFloatMillis)
  - `deleting` (boolean)
    Indicates that the process of deleting the job is in progress but not yet completed. It is only reported when `true`.
## Code Examples

#### Console

```console
GET _ml/anomaly_detectors/low_request_rate/_stats
```

#### JavaScript

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

#### Python

```python
resp = client.ml.get_job_stats(
    job_id="low_request_rate",
)
```

#### curl

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

#### Java

```java
client.ml().getJobStats(g -> g
    .jobId("low_request_rate")
);
```

#### C#

```c#
var response = await client.MachineLearning
    .GetJobStatsAsync(d1 => d1
        .JobId("low_request_rate")
    );
```

#### PHP

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

#### Ruby

```ruby
response = client.ml.get_job_stats(
  job_id: "low_request_rate"
)
```

