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

# Get Watcher statistics


Availability: 5.5+

## Paths

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

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

#### Path Parameters

- `metric` (union WatcherMetric | [] WatcherMetric) — 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`

## Query String Parameters

- `emit_stacktraces` (boolean · default: false)
  Defines whether stack traces are generated for each watch that is running.
- `metric` (union WatcherMetric | [] WatcherMetric)
  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` ({} NodeStatistics)
  - `failures` ([] ErrorCause)
    - `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` ({} ErrorCause) — recursive
      Same fields as `failures` in `_nodes`
    - `root_cause` ([] ErrorCause) — recursive
      Same fields as `failures` in `_nodes`
    - `suppressed` ([] ErrorCause) — 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 Name)
- `manually_stopped` (boolean)
- `stats` ([] WatcherNodeStats)
  - `current_watches` ([] WatchRecordStats)
    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` (DateTime)
      The time the watch was run.
This is just before the input is being run.
    - `execution_phase` (enum ExecutionPhase)
      The current watch execution phase.
      Values: `awaits_execution`, `started`, `input`, `condition`, `actions`, `watch_transform`, `aborted`, `finished`
    - `triggered_time` (DateTime)
      The time the watch was triggered by the trigger engine.
    - `executed_actions` ([] string)
    - `watch_id` (string Id)
    - `watch_record_id` (string Id)
      The watch record identifier.
  - `execution_thread_pool` ({} ExecutionThreadPool)
    - `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` ([] WatchRecordQueuedStats)
    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` (DateTime)
      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 WatcherState)
    The current state of Watcher.
    Values: `stopped`, `starting`, `started`, `stopping`
  - `node_id` (string Id)
## 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" 
        }
  ]
}
```

