OpenSearch is an open-source search and analytics suite, while Amazon OpenSearch Service is a managed service on Amazon Web Services that allows organizations to host and manage OpenSearch clusters in the cloud.
In this blog, we will discuss OpenSearch index automatic rollover using ISM policies, an issue faced by one of our clients, and how we successfully solved it.
One of our clients had an architecture where logs were pushed continuously from multiple servers and environments into an OpenSearch cluster using Fluent Bit.
Architecture Overview
Servers (multiple environments)
→ Fluent Bit log forwarder
→ AWS OpenSearch cluster
The first thing we noticed was that their indexes were growing at a rate of more than 100 GB per day. Logs were ingested from multiple development environments continuously, which made automatic index rollover mandatory for cluster stability.
The client attempted to implement an OpenSearch ISM rollover policy to automatically roll over indexes when the primary shard size reached a certain threshold. However, the rollover kept failing every time it triggered.
Implementing OpenSearch automatic rollover is critical in log-heavy architectures.
Benefits include:
According to official OpenSearch recommendations, the optimal primary shard size should be between 30 GB and 50 GB.
Why?
| Shard Size | Impact |
| Too Small | Too many shards → cluster overhead |
| Optimal (30–50GB) | Balanced performance |
| Too Large | Memory pressure and slow recovery |
Large shards require more memory and can lead to out-of-memory errors. Copy and recovery operations also become slower with oversized shards.
Maintaining optimal shard sizes significantly improves cluster performance.
ISM (Index State Management) policies control the lifecycle of an index.
An ISM policy in OpenSearch consists of:
The policy execution interval determines how frequently OpenSearch evaluates rollover conditions.
If the cluster health becomes red, certain lifecycle operations like rollover can fail or be delayed.
One of the most common reasons OpenSearch index rollover fails is incorrect index naming.
For automatic rollover to work, the index name must follow this pattern:
^.*-\d+$
Example valid index names:
This naming pattern allows OpenSearch to automatically generate the next sequential index name during rollover.
Below is a simple OpenSearch index automatic rollover example using ISM policies.
An index template defines the general configuration applied to indexes that match a certain pattern.
Example:
PUT _index_template/mafiree-index-template
{
"index_patterns": [
"mafiree*"
],
"template": {
"settings": {
"index.number_of_shards": "3",
"index.number_of_replicas": "2"
}
},
"composed_of": [],
"priority": "100",
"_meta": {
"flow": "simple"
}
}This template applies the configuration to all indexes that match mafiree*.
An ISM policy defines lifecycle actions for indexes.
Example policy:
PUT _plugins/_ism/policies/mafiree-rollover-policy
{
"policy": {
"description": "ISM policy to keep the size of each primary shard optimal",
"default_state": "rollover",
"states": [
{
"name": "rollover",
"actions": [
{
"rollover": {
"min_primary_shard_size": "30gb"
}
}
],
"transitions": []
}
],
"ism_template": {
"index_patterns": ["mafiree*"],
"priority": 100
}
}
}This OpenSearch ISM rollover policy triggers rollover once the primary shard size reaches 30 GB.
You can create indexes via:
In OpenSearch, an alias acts as a pointer to an index.
A rollover alias allows applications to write data without changing the index name after rollover.
Example:
POST /mafiree*/_alias/mafiree-rollover-alias
This alias routes requests to indexes matching mafiree*.
Now we connect everything together.
PUT _index_template/mafiree-index-template
{
"index_patterns": [
"mafiree*"
],
"template": {
"settings": {
"index.number_of_shards": "3",
"index.number_of_replicas": "2",
"index.plugins.index_state_management.rollover_alias": "mafiree-rollover-alias"
}
},
"composed_of": [],
"priority": "100",
"_meta": {
"flow": "simple"
}
}This setting ensures all indexes created through the template automatically use the rollover alias.
If you are using AWS OpenSearch, you can monitor rollover status from the dashboard.
Navigate to:
Many users struggle with OpenSearch automatic rollover not triggering.
Common causes include:
Error:
Missing rollover_alias index setting
Fix: Add
index.plugins.index_state_management.rollover_alias
to the index template.
If your index does not match:
^.*-\d+$
automatic rollover will fail.
The alias must point to the current write index.
Ensure the ISM policy is applied to the index pattern.
Check if the shard size has actually crossed:
min_primary_shard_size
If cluster health is red, rollover actions may not execute.
A typical ISM lifecycle policy may include multiple phases:
| Phase | Purpose |
| Hot | Active indexing |
| Warm | Reduced resources |
| Delete | Remove old indexes |
This lifecycle helps reduce storage cost while maintaining performance.
Best practices for OpenSearch index rollover in production:
By recreating the configuration in a controlled test environment, we were able to identify the missing pieces and properly implement OpenSearch index automatic rollover using ISM policies. After applying the correct index templates, ISM policies, naming patterns, and rollover alias configuration, the client’s OpenSearch cluster began rolling over indexes automatically without any failures. If you are facing similar challenges with your OpenSearch cluster, feel free to reach out to us at sales@mafiree.com. Our team can help you optimize your cluster, improve performance, and ensure smooth index lifecycle management.
Miru IT Park, Vallankumaranvillai,
Nagercoil, Tamilnadu - 629 002.
Unit 303, Vanguard Rise,
5th Main, Konena Agrahara,
Old Airport Road, Bangalore - 560 017.
Call: +91 6383016411
Email: sales@mafiree.com