Create an auto-follow pattern to replicate time series indices

edit

Create an auto-follow pattern to replicate time series indices

edit

You use auto-follow patterns to automatically create new followers for rolling time series indices. Whenever the name of a new index on the remote cluster matches the auto-follow pattern, a corresponding follower index is added to the local cluster. Note that only indices created on the remote cluster after the auto-follow pattern is created will be auto-followed: existing indices on the remote cluster are ignored even if they match the pattern.

An auto-follow pattern specifies the remote cluster you want to replicate from, and one or more index patterns that specify the rolling time series indices you want to replicate.

To create an auto-follow pattern from Stack Management in Kibana:

  1. Select Cross Cluster Replication in the side navigation and choose the Auto-follow patterns tab.
  2. Enter a name for the auto-follow pattern, such as beats.
  3. Choose the remote cluster that contains the index you want to replicate, which in the example scenario is Cluster A.
  4. Enter one or more index patterns that identify the indices you want to replicate from the remote cluster. For example, enter metricbeat-* packetbeat-* to automatically create followers for Metricbeat and Packetbeat indices.
  5. Enter follower- as the prefix to apply to the names of the follower indices so you can more easily identify replicated indices.

As new indices matching these patterns are created on the remote, Elasticsearch automatically replicates them to local follower indices.

The Auto-follow patterns page in Kibana
API example

Use the create auto-follow pattern API to configure auto-follow patterns.

resp = client.ccr.put_auto_follow_pattern(
    name="beats",
    remote_cluster="leader",
    leader_index_patterns=[
        "metricbeat-*",
        "packetbeat-*"
    ],
    follow_index_pattern="{{leader_index}}-copy",
)
print(resp)
const response = await client.ccr.putAutoFollowPattern({
  name: "beats",
  remote_cluster: "leader",
  leader_index_patterns: ["metricbeat-*", "packetbeat-*"],
  follow_index_pattern: "{{leader_index}}-copy",
});
console.log(response);
PUT /_ccr/auto_follow/beats
{
  "remote_cluster" : "leader",
  "leader_index_patterns" :
  [
    "metricbeat-*", 
    "packetbeat-*" 
  ],
  "follow_index_pattern" : "{{leader_index}}-copy" 
}

Automatically follow new Metricbeat indices.

Automatically follow new Packetbeat indices.

The name of the follower index is derived from the name of the leader index by adding the suffix -copy to the name of the leader index.