---
type: api
title: Get cross-cluster replication stats
description: This API returns stats about auto-following and the same shard-level stats as the get follower stats API.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ccr-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ccr-stats
products:
  - Elasticsearch
---

# Get cross-cluster replication stats

Availability: 6.5+

## Paths

- `GET` `/_ccr/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)

## Description

This API returns stats about auto-following and the same shard-level stats as the get follower stats API.

## Required authorization

* Cluster privileges: `monitor`

## Query String Parameters

- `master_timeout` (string Duration · default: 30s)
  The period to wait for a connection to the master node.
If the master node is not available before the timeout expires, the request fails and returns an error.
It can also be set to `-1` to indicate that the request should never timeout.
- `timeout` (string Duration · default: 30s)
  The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

## Response

`application/json`

- `auto_follow_stats` ({} AutoFollowStats)
  Statistics for the auto-follow coordinator.
  - `auto_followed_clusters` ([] AutoFollowedCluster)
    - `cluster_name` (string Name)
    - `last_seen_metadata_version` (number VersionNumber)
    - `time_since_last_check_millis` (DurationValueUnitMillis)
  - `number_of_failed_follow_indices` (number)
    The number of indices that the auto-follow coordinator failed to automatically follow.
The causes of recent failures are captured in the logs of the elected master node and in the `auto_follow_stats.recent_auto_follow_errors` field.
  - `number_of_failed_remote_cluster_state_requests` (number)
    The number of times that the auto-follow coordinator failed to retrieve the cluster state from a remote cluster registered in a collection of auto-follow patterns.
  - `number_of_successful_follow_indices` (number)
    The number of indices that the auto-follow coordinator successfully followed.
  - `recent_auto_follow_errors` ([] ErrorCause)
    An array of objects representing failures by the auto-follow coordinator.
    - `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 `recent_auto_follow_errors` in `auto_follow_stats`
    - `root_cause` ([] ErrorCause) — recursive
      Same fields as `recent_auto_follow_errors` in `auto_follow_stats`
    - `suppressed` ([] ErrorCause) — recursive
      Same fields as `recent_auto_follow_errors` in `auto_follow_stats`
- `follow_stats` ({} FollowStats)
  Shard-level statistics for follower indices.
  - `indices` ([] FollowIndexStats)
    - `index` (string IndexName)
      The name of the follower index.
    - `shards` ([] ShardStats)
      An array of shard-level following task statistics.
      - `bytes_read` (number)
        The total of transferred bytes read from the leader.
This is only an estimate and does not account for compression if enabled.
      - `failed_read_requests` (number)
        The number of failed reads.
      - `failed_write_requests` (number)
        The number of failed bulk write requests on the follower.
      - `fatal_exception` ({} 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 `fatal_exception` in `shards`
        - `root_cause` ([] ErrorCause) — recursive
          Same fields as `fatal_exception` in `shards`
        - `suppressed` ([] ErrorCause) — recursive
          Same fields as `fatal_exception` in `shards`
      - `follower_aliases_version` (number VersionNumber)
        The index aliases version the follower is synced up to.
      - `follower_global_checkpoint` (number)
        The current global checkpoint on the follower.
The difference between the `leader_global_checkpoint` and the `follower_global_checkpoint` is an indication of how much the follower is lagging the leader.
      - `follower_index` (string)
        The name of the follower index.
      - `follower_mapping_version` (number VersionNumber)
        The mapping version the follower is synced up to.
      - `follower_max_seq_no` (number SequenceNumber)
        The current maximum sequence number on the follower.
      - `follower_settings_version` (number VersionNumber)
        The index settings version the follower is synced up to.
      - `last_requested_seq_no` (number SequenceNumber)
        The starting sequence number of the last batch of operations requested from the leader.
      - `leader_global_checkpoint` (number)
        The current global checkpoint on the leader known to the follower task.
      - `leader_index` (string)
        The name of the index in the leader cluster being followed.
      - `leader_max_seq_no` (number SequenceNumber)
        The current maximum sequence number on the leader known to the follower task.
      - `operations_read` (number)
        The total number of operations read from the leader.
      - `operations_written` (number)
        The number of operations written on the follower.
      - `outstanding_read_requests` (number)
        The number of active read requests from the follower.
      - `outstanding_write_requests` (number)
        The number of active bulk write requests on the follower.
      - `read_exceptions` ([] ReadException)
        An array of objects representing failed reads.
        - `exception` ({} ErrorCause)
          The exception that caused the read to fail.
          - `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 `exception` in `read_exceptions`
          - `root_cause` ([] ErrorCause) — recursive
            Same fields as `exception` in `read_exceptions`
          - `suppressed` ([] ErrorCause) — recursive
            Same fields as `exception` in `read_exceptions`
        - `from_seq_no` (number SequenceNumber)
          The starting sequence number of the batch requested from the leader.
        - `retries` (number)
          The number of times the batch has been retried.
      - `remote_cluster` (string)
        The remote cluster containing the leader index.
      - `shard_id` (number)
        The numerical shard ID, with values from 0 to one less than the number of replicas.
      - `successful_read_requests` (number)
        The number of successful fetches.
      - `successful_write_requests` (number)
        The number of bulk write requests run on the follower.
      - `time_since_last_read` (string Duration)
      - `time_since_last_read_millis` (DurationValueUnitMillis)
        The number of milliseconds since a read request was sent to the leader.
When the follower is caught up to the leader, this number will increase up to the configured `read_poll_timeout` at which point another read request will be sent to the leader.
      - `total_read_remote_exec_time` (string Duration)
      - `total_read_remote_exec_time_millis` (DurationValueUnitMillis)
        The total time reads spent running on the remote cluster.
      - `total_read_time` (string Duration)
      - `total_read_time_millis` (DurationValueUnitMillis)
        The total time reads were outstanding, measured from the time a read was sent to the leader to the time a reply was returned to the follower.
      - `total_write_time` (string Duration)
      - `total_write_time_millis` (DurationValueUnitMillis)
        The total time spent writing on the follower.
      - `write_buffer_operation_count` (number)
        The number of write operations queued on the follower.
      - `write_buffer_size_in_bytes` (number | string ByteSize)
        The total number of bytes of operations currently queued for writing.
## Code Examples

#### Console

```console
GET /_ccr/stats
```

#### JavaScript

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

#### Python

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

#### curl

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

#### Java

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

#### C#

```c#
var response = await client.CrossClusterReplication.StatsAsync();
```

#### PHP

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

#### Ruby

```ruby
response = client.ccr.stats
```

## Response Examples

#### Ccr stats response example1

A successful response from `GET /_ccr/stats` that returns cross-cluster replication stats.

```json
{
  "auto_follow_stats" : {
    "number_of_failed_follow_indices" : 0,
    "number_of_failed_remote_cluster_state_requests" : 0,
    "number_of_successful_follow_indices" : 1,
    "recent_auto_follow_errors" : [],
    "auto_followed_clusters" : []
  },
  "follow_stats" : {
    "indices" : [
      {
        "index" : "follower_index",
        "total_global_checkpoint_lag" : 256,
        "shards" : [
          {
            "remote_cluster" : "remote_cluster",
            "leader_index" : "leader_index",
            "follower_index" : "follower_index",
            "shard_id" : 0,
            "leader_global_checkpoint" : 1024,
            "leader_max_seq_no" : 1536,
            "follower_global_checkpoint" : 768,
            "follower_max_seq_no" : 896,
            "last_requested_seq_no" : 897,
            "outstanding_read_requests" : 8,
            "outstanding_write_requests" : 2,
            "write_buffer_operation_count" : 64,
            "follower_mapping_version" : 4,
            "follower_settings_version" : 2,
            "follower_aliases_version" : 8,
            "total_read_time_millis" : 32768,
            "total_read_remote_exec_time_millis" : 16384,
            "successful_read_requests" : 32,
            "failed_read_requests" : 0,
            "operations_read" : 896,
            "bytes_read" : 32768,
            "total_write_time_millis" : 16384,
            "write_buffer_size_in_bytes" : 1536,
            "successful_write_requests" : 16,
            "failed_write_requests" : 0,
            "operations_written" : 832,
            "read_exceptions" : [ ],
            "time_since_last_read_millis" : 8
          }
        ]
      }
    ]
  }
}
```

