---
type: api
title: Get Watcher statistics
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-watcher-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-watcher-stats
products:
  - Elasticsearch
---

# Get Watcher statistics


Availability: Generally available since 5.5

## Paths

- `GET` `/_watcher/stats/{metric}`
- `GET` `/_watcher/stats`

#### Path parameters

- `metric` (union enum | enum[]) — optional, leave it out to use `/_watcher/stats`
  Defines which additional metrics are included in the response.

Supported values include: `_all` (or `all`), `queued_watches`, `current_watches`, `pending_watches`
  Values: `_all`, `all`, `queued_watches`, `current_watches`, `pending_watches`

## Description

This API always returns basic metrics.
You retrieve more metrics by using the metric parameter.

## Required authorization

- Cluster privileges: `monitor_watcher`

## 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/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `emit_stacktraces` (boolean · default: false) — optional
  Defines whether stack traces are generated for each watch that is running.
- `metric` (union enum | enum[]) — optional
  Defines which additional metrics are included in the response.

Supported values include: `_all` (or `all`), `queued_watches`, `current_watches`, `pending_watches`
  Values: `_all`, `all`, `queued_watches`, `current_watches`, `pending_watches`

## Response

`application/json`

- `_nodes` (object)
  - `failures` (object[])
    - `type` (string)
      The type of error
    - `reason` (union string) — nullable
      A human-readable explanation of the error, in English.
      One of: `string`
    - `stack_trace` (string)
      The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
    - `caused_by` (object) — recursive
      Same fields as `failures` in `_nodes`
    - `root_cause` (object[]) — recursive
      Same fields as `failures` in `_nodes`
    - `suppressed` (object[]) — recursive
      Same fields as `failures` in `_nodes`
  - `total` (number)
    Total number of nodes selected by the request.
  - `successful` (number)
    Number of nodes that responded successfully to the request.
  - `failed` (number)
    Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response.
- `cluster_name` (string)
- `manually_stopped` (boolean)
- `stats` (object[])
  - `current_watches` (object[])
    The current executing watches metric gives insight into the watches that are currently being executed by Watcher.
Additional information is shared per watch that is currently executing.
This information includes the `watch_id`, the time its execution started and its current execution phase.
To include this metric, the `metric` option should be set to `current_watches` or `_all`.
In addition you can also specify the `emit_stacktraces=true` parameter, which adds stack traces for each watch that is being run.
These stack traces can give you more insight into an execution of a watch.
    - `execution_time` (union)
      The time the watch was run.
This is just before the input is being run.
    - `execution_phase` (enum)
      The current watch execution phase.
      Values: `awaits_execution`, `started`, `input`, `condition`, `actions`, `watch_transform`, `aborted`, `finished`
    - `triggered_time` (union)
      The time the watch was triggered by the trigger engine.
    - `executed_actions` (string[])
    - `watch_id` (string)
    - `watch_record_id` (string)
      The watch record identifier.
  - `execution_thread_pool` (object)
    - `max_size` (number)
      The largest size of the execution thread pool, which indicates the largest number of concurrent running watches.
    - `queue_size` (number)
      The number of watches that were triggered and are currently queued.
  - `queued_watches` (object[])
    Watcher moderates the execution of watches such that their execution won't put too much pressure on the node and its resources.
If too many watches trigger concurrently and there isn't enough capacity to run them all, some of the watches are queued, waiting for the current running watches to finish.s
The queued watches metric gives insight on these queued watches.

To include this metric, the `metric` option should include `queued_watches` or `_all`.
    - `execution_time` (union)
      The time the watch was run.
This is just before the input is being run.
  - `watch_count` (number)
    The number of watches currently registered.
  - `watcher_state` (enum)
    The current state of Watcher.
    Values: `stopped`, `starting`, `started`, `stopping`
  - `node_id` (string)
## Code examples

#### Console

```console
GET _watcher/stats
```

#### JavaScript

```javascript
const response = await client.watcher.stats();
```

#### Python

```python
resp = client.watcher.stats()
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_watcher/stats" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.watcher().stats(s -> s);
```

#### PHP

```php
$resp = $client->watcher()->stats();
```

#### Ruby

```ruby
response = client.watcher.stats
```

## Response examples

#### Basic metrics

A successful response from `GET _watcher/stats`.

```json
{
  "watcher_state": "started",  
  "watch_count": 1, 
  "execution_thread_pool": {
    "size": 1000, 
    "max_size": 1 
  }
}
```

#### Current watch metrics

A successful response from `GET _watcher/stats?metric=current_watches`.

```json
{
  "watcher_state": "started",
  "watch_count": 2,
  "execution_thread_pool": {
      "queue_size": 1000,
      "max_size": 20
  },
  "current_watches": [ 
      {
        "watch_id": "slow_condition", 
        "watch_record_id": "slow_condition_3-2015-05-13T07:42:32.179Z", 
        "triggered_time": "2015-05-12T11:53:51.800Z", 
        "execution_time": "2015-05-13T07:42:32.179Z", 
        "execution_phase": "condition" 
      }
  ]
}
```

#### Queued watch metrics

An abbreviated response from `GET _watcher/stats/queued_watches`.

```json
{
  "watcher_state": "started",
  "watch_count": 10,
  "execution_thread_pool": {
      "queue_size": 1000,
      "max_size": 20
  },
  "queued_watches": [ 
        {
            "watch_id": "slow_condition4", 
            "watch_record_id": "slow_condition4_223-2015-05-21T11:59:59.811Z", 
            "triggered_time": "2015-05-21T11:59:59.811Z", 
            "execution_time": "2015-05-21T11:59:59.811Z" 
        }
  ]
}
```

