Iterative Methods

Managing Aliases

static curator.alias(client, dry_run=False, **kwargs)

Multiple use cases:

  1. Add indices alias_older_than n time_units, matching the given timestring, prefix, and suffix to alias.
  2. Remove indices unalias_older_than n time_units, matching the given timestring, prefix, and suffix to alias.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.add_to_alias()

curator.curator.add_to_alias()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • alias – Alias name to operate on.
  • alias_older_than – Indices older than the indicated number of whole time_units will be operated on.
  • unalias_older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Shard-Awareness Allocation Rules

static curator.allocation(client, dry_run=False, **kwargs)

Change shard/routing allocation for indices older_than n time_units, matching the given timestring, prefix, and suffix by updating/applying the provided rule.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.apply_allocation_rule()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • rule – The routing allocation rule to apply, e.g. tag=ssd. Must be in the format of key=value, and should match values declared on the correlating nodes in your cluster.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Disable Bloom Filter Cache

static curator.bloom(client, dry_run=False, **kwargs)

Disable bloom filter cache for indices older_than n time_units, matching the given timestring, prefix, and suffix.

Can optionally delay a given number of seconds after each optimization.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.disable_bloom_filter()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • delay – Pause n seconds after optimizing an index.
  • utc_now – Used for testing. Overrides current time with specified time.

Close Indices

static curator.close(client, dry_run=False, **kwargs)

Close indices older_than n time_units, matching the given timestring, prefix, and suffix.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.close_index()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Delete Indices

static curator.delete(client, dry_run=False, **kwargs)

Two use cases for deleting indices:

  1. Delete indices older_than n time_units, matching the given timestring, prefix, and suffix.
  2. Delete indices in excess of disk_space gigabytes if the disk_space kwarg is present, beginning from the oldest. Indices must still match prefix and suffix. This amount spans all nodes and shards and must be calculated accordingly. This is not a recommended use-case.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_space()

curator.curator.filter_by_timestamp()

curator.curator.delete_index()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • disk_space – Delete indices over n gigabytes, starting from the oldest indices.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Optimize Indices

static curator.optimize(client, dry_run=False, **kwargs)

Optimize indices older_than n time_units, matching the given timestring, prefix, and suffix to max_num_segments segments per shard.

Can optionally delay a given number of seconds after each optimization.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.optimize_index()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If True, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • max_num_segments – Merge to this number of segments per shard.
  • delay – Pause n seconds after optimizing an index.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Change Replica Count of Indices

static curator.replicas(client, dry_run=False, **kwargs)

Change replica count for indices older_than n time_units, matching the given timestring, prefix, and suffix.

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.close_index()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • replicas – The number of replicas the index should have
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.

Snapshot Indices

static curator.snapshot(client, dry_run=False, **kwargs)

Multiple use cases:

  1. Snapshot indices older_than n time_units, matching the given timestring, prefix, and suffix into repository.
  2. Snapshot n most_recent indices matching prefix and suffix into repository.
  3. delete_older_than n time_units matching the given timestring, prefix, and suffix from repository.
  4. Snapshot all_indices (ignoring older_than and most_recent).

Note

As this is an iterative function, default values are handled by the target function(s).

Unless passed in kwargs, parameters other than client and dry_run will have default values assigned by the functions being called:

curator.curator.get_object_list()

curator.curator.filter_by_timestamp()

curator.curator.create_snapshot()

curator.curator.delete_snapshot()

These defaults are included here for documentation.

Parameters:
  • client – The Elasticsearch client connection
  • dry_run – If true, simulate, but do not perform the operation
  • older_than – Indices older than the indicated number of whole time_units will be operated on.
  • most_recent – Most recent n indices will be operated on.
  • all_indices (bool) – Boolean. Include _all indices in snapshot.
  • delete_older_than – Snapshots older than the indicated number of whole time_units will be operated on.
  • time_unit – One of hours, days, weeks, months. Default is days.
  • timestring – An strftime string to match the datestamp in an index name.
  • snapshot_name – Override the default with this value. Defaults to None
  • snapshot_prefix – Override the default with this value. Defaults to curator-
  • prefix – A string that comes before the datestamp in an index name. Can be empty. Wildcards acceptable. Default is logstash-.
  • suffix – A string that comes after the datestamp of an index name. Can be empty. Wildcards acceptable. Default is empty, ''.
  • repository – The Elasticsearch snapshot repository to use
  • wait_for_completion (bool) – Wait (or not) for the operation to complete before returning. Waits by default, i.e. Default is True
  • ignore_unavailable (bool) – Ignore unavailable shards/indices. Default is False
  • include_global_state (bool) – Store cluster global state with snapshot. Default is True
  • partial (bool) – Do not fail if primary shard is unavailable. Default is False
  • exclude_pattern – Exclude indices matching the provided regular expression.
  • utc_now – Used for testing. Overrides current time with specified time.