OpenSearch index lifecycle and data retention

Index State Management policies move OpenSearch indices through rollover, shrink, move and delete on a schedule. This guide covers the decisions, build sequence, effort drivers and checks that keep retention and storage costs under control.

On this page

Why OpenSearch index lifecycle decisions need to be made before data arrives

The decisions that determine how long OpenSearch keeps data have to be made before the first document is indexed. Log, observability and security data grows every day, and the retention rules that govern it usually come from legal, audit or security teams who may not think in terms of indices, shards or policies. Before any configuration is written, the platform team should collect those requirements and translate them into a small set of retention classes, each with a defined period, a storage tier and an owner who can approve changes. Asking for these rules after ingestion has started means deciding retention for data that already exists, often under pressure and without a clear record of what was promised.

OpenSearch Index State Management (ISM) automates the lifecycle of indices. An ISM policy defines states and actions, such as rolling an index over when it reaches a size or age, shrinking it, moving it to different nodes and deleting it on schedule. The configuration itself is not the hard part. The hard part is agreeing three things first: the retention classes, the index naming convention that lets a policy identify which indices belong to which class, and how each class ties to snapshots and to who can read the data. A naming scheme chosen after the fact usually forces either manual renaming or policies that match too broadly.

Several characteristics make this harder than it looks. ISM policies apply to indices through index patterns, and a policy can be attached to indices that already exist, so a pattern that is too broad can bring old data under a deletion rule nobody intended. Deletion is irreversible within the cluster: once an index is deleted, the only way back is a snapshot taken earlier, so the snapshot schedule and its retention must be designed alongside the delete action. Access rules need the same care, because role mappings that grant reads on a pattern may expose data that a retention class is supposed to restrict.

Retention also has to be proven, not just configured. An auditor will ask what the policy says, which indices it covered on a given date, when they were deleted, and whether snapshots of protected data exist for the required period. The team should plan to produce this evidence from the cluster itself, including policy definitions, ISM explain output, snapshot records and the audit logs that the Security plugin can provide, and should confirm with the auditor which formats and time ranges they accept. Testing a restore from a snapshot before it is needed is the most direct way to show that the retention design works.

Which OpenSearch components and settings control index lifecycle

Index lifecycle in OpenSearch is not one setting. It is a chain: a policy in the Index State Management plugin, index templates that attach that policy, rollover aliases that point writes at the current index, node roles that place data by age, snapshot repositories that protect data before it is removed, and shard and replica settings that shape each index. Review each component together so retention rules behave the way your compliance team expects.

Index State Management policy model

The Index State Management (ISM) plugin runs policies that move each index through named states. Every state holds actions such as rollover, shrink, move between node types, replica count changes, snapshot, and delete, and transitions decide when an index moves to the next state based on age, size, or document count. Map each retention rule to a state and transition, then confirm action names and options against the OpenSearch version you run, since they change between releases.

Index templates that attach policies

Index templates apply settings and mappings to new indices as they are created, and they can also set the ISM policy that governs those indices. A template that matches your log or event naming pattern ensures that every new index gets the same retention path without manual steps. Check the template priority and pattern overlaps, because a broader template can silently override a narrower one for the same index name.

Rollover aliases and write indices

A rollover alias gives applications one stable name for writing while the underlying index changes as it fills. The alias must point to exactly one write index, and the rollover action creates the next index and moves that write designation. Test rollover with your real ingest path, and confirm that every client writes through the alias rather than a concrete index name, or retention will not apply to the data they send.

Node roles for hot, warm and cold data

Data node roles decide where shards can live. Hot nodes take new writes and recent queries, while warm or cold tiers hold older indices on slower or cheaper storage, and ISM actions move indices between them using node attributes. Confirm which tier types your environment provides, how node attributes are labeled, and whether dedicated cluster manager nodes are present, because those choices limit where the move action can place data.

Snapshot repositories before deletion

A snapshot repository is the copy of an index kept outside the cluster before a delete action removes it from the cluster. Define the repository, its storage location and access permissions before enabling delete states, and decide whether snapshots are part of the retention period or a separate archive rule. Verify restores on a test cluster, because a snapshot that cannot be restored does not satisfy a retention or recovery requirement.

Shard and replica settings in cluster and index scope

Cluster settings and index-level settings control how shards and replicas are allocated across nodes, zones and tiers. Shard allocation awareness keeps replicas on different zones, and index settings such as replica count, shard count and allocation filters determine what the lifecycle actions can change. Review these settings with the team that owns availability, since a lifecycle move that reduces replicas can weaken recovery during a node or zone loss.

Choosing rollover size or age, tiering method and delete strategy

This table compares the main lifecycle choices for OpenSearch indices, from rollover triggers to tiering and deletion, and states when each fits and what it costs to operate. Read each row as a decision: the right option depends on how your data arrives, how long you must keep it, and how much operational work your team can absorb. The main takeaway is that the cheapest-looking option often moves cost into shard management, snapshot storage or recovery risk.

DecisionWhen it fitsOperational cost to plan for
Time-based rolloverSteady ingestion where daily or weekly indices map cleanly to retention rules and reporting periodsIndex sizes can vary widely during traffic spikes, so shard sizes may drift away from the target you set in the cluster sizing plan
Size-based rolloverBursty or uneven ingestion where you want shards to stay near a chosen size regardless of volumeIndices can roll at odd times, which makes date-based retention and searches across periods harder to reason about
Single cluster with hot and warm node attributesOne team owns the cluster and needs moves between tiers without moving data across clustersShard allocation rules, node attributes and warm node capacity all need monitoring, and a misconfigured allocation filter can stall moves
Separate hot and warm clustersCompliance or ownership boundaries require isolated environments, or warm data has very different access patternsMore clusters to patch, upgrade, secure and back up, and cross-cluster queries add latency and configuration work
Shrink after rolloverRead-heavy indices that no longer receive writes and benefit from fewer, larger shardsShrink needs a write-blocked source index and temporary disk headroom, and it adds steps that can fail partway through
Keep indices full sizeShort retention windows or indices that stay write-active until deletionShard count stays high, which increases cluster state and heap pressure as retention grows
Delete onlyData with no retention or recovery requirement beyond the cluster itselfDeleted indices cannot be restored unless a usable snapshot exists, so this carries the highest risk of permanent loss
Snapshot then deleteRetention rules require recoverable history or audit evidence after data leaves the live clusterExtra snapshot storage recurs each period, and snapshot repository access, encryption and restore testing need ongoing ownership

How to build an ISM policy from retention requirement to verified delete

This sequence turns a retention requirement into an Index State Management policy that rolls, moves and deletes indices on schedule, then proves the policy works before production. Each step closes with a check the team can repeat, so every delete traces back to the requirement that justified it. The work runs in the client's own cluster, storage and accounts.

  1. Inventory indices and owners

    The platform team lists every index pattern, data stream and alias in the cluster, along with the business owner who can confirm what each one holds and why it exists. Owners state the purpose, the data classification and any legal or contractual hold that applies. Ask for the index list and the owner sign-off in writing. The step is done when every index pattern has a named owner, because unowned indices are the ones that never get deleted and quietly drive storage costs.

  2. Map each index pattern to a retention class

    Security, legal and business owners agree on a small set of retention classes, each with a minimum keep period, a maximum period and a rule for what happens at the end. Each index pattern or data stream is assigned to exactly one class, and the mapping is written down in a table that auditors and owners can read. Confirm each period against its source, such as a regulation, contract or internal policy, and record who approved it. The check is a mapping table with no unassigned patterns and an approver named for each class.

  3. Define policy states and actions

    Using the retention classes, the engineer writes an ISM policy as a set of states, such as hot, warm and delete, with the actions that run in each state. Typical actions include rollover, force merge, allocation changes, snapshot and delete, and transitions are triggered by conditions such as index age, size or document count. Confirm that each action and condition is supported by the OpenSearch version in use before it goes into the policy. The check is a policy document that passes validation on a test cluster and a state diagram the data owner has signed off.

  4. Create index templates with the policy and rollover alias

    Each index template attaches the policy to new indices that match its pattern, sets the rollover alias and the write index, and carries the shard and replica settings chosen during sizing. Data streams receive the policy through their template as well. Existing indices do not pick up a template retroactively, so the team lists them and attaches the policy by name. The check is the explain output for a sample new index showing the policy ID, current state and next action, plus the same output for an existing index that was attached manually.

  5. Set node attributes and allocation rules for tiers

    Platform engineers tag each data node with a tier attribute that matches the hardware it runs on, such as hot or warm. The policy's allocation actions then move indices to the right tier at each transition. Confirm which tier types the chosen distribution and hardware support, and confirm that each tier has enough capacity before any policy depends on it. The check is a test index moved by an allocation action, with shard relocation observed on the nodes carrying the expected attribute.

  6. Configure snapshot repositories and a snapshot schedule

    Before any delete action runs, a snapshot repository must exist and hold the copies that the retention class requires. The team registers the repository in the client's own storage, restricts access to it, and creates a snapshot schedule that matches each retention class. The data owner decides how long snapshots are kept, which can differ from how long the live index is kept. The check is a scheduled snapshot that completes successfully and appears in the repository listing.

  7. Test the policy on a non-production cluster

    The team copies the policy, templates and tier rules to a non-production cluster and runs them with short, illustrative ages so that a test index passes through every state in a compressed window. Watch the explain output as the index changes state, confirm that the delete action removes it, and then restore an earlier snapshot and run a read test to confirm the data is intact. Record the results and promote the policy through the normal change process. The check is a passed read test on the restored data and a log entry showing the test index was deleted by the policy.

How to turn retention requirements into policy states the cluster can enforce

Retention rules are usually written as durations per data class, such as keeping a category of records for a stated period after an event. Index State Management does not work with data classes. It evaluates each index against a policy's states and conditions, using index age, document count, index size and rollover thresholds. Before writing any policy JSON, build a mapping table with one row per requirement. Each row should name the data class, the index pattern that carries it, the retention start event, the retention length, the action that ends retention and the ISM policy that will enforce it. A requirement that cannot fill every column is not yet ready to be enforced.

Group requirement categories by the retention behavior they need, then create one policy template for each group. A template pairs an index pattern with a policy through an ISM template, and the priority field decides which template wins when several match. Templates apply to indices created after they exist, so existing indices need an explicit policy assignment. The retention start date is the main point of friction. ISM ages an index from its creation time, and after a rollover the age of the new backing index starts again. If the compliance owner counts retention from the event timestamp in the data, an index-age rule can keep records too long or delete them too early. Confirm this for each source before setting min_index_age values.

Legal holds and extended retention need their own design, because a standard delete state will remove held data on schedule. One approach is to give held indices a policy with no delete action, assigned explicitly through the change policy API. Another is to route held data into a separate index pattern that no delete template matches. Either way, new rollover indices must inherit the hold, so test that a rollover of a held index produces a successor that stays protected. Record who approved each hold, the scope, and the release procedure. Confirm with your compliance owner whether a hold must be logged outside the cluster, and whether the audit logs from the Security plugin satisfy that need.

Overlapping patterns are the most common source of silent policy conflicts. A hold pattern, a general log pattern and a security pattern can all match the same index name. Keep a register of every index pattern and its priority, and give each template a unique priority so no two overlapping templates tie. After any change, create a sample index with a representative name in a test environment and confirm which policy attaches, then check the managed index status for each live index. Verify the exact matching and priority behavior in the documentation for your OpenSearch version before relying on it, because the rules that decide conflicts are the ones most likely to surprise an operations team.

What drives the effort and cost of index lifecycle work

This table lists the factors that move the effort of OpenSearch index lifecycle work, how each one changes the scope, and how to keep it contained. Read it before asking for a quote, because most of the variation in scope comes from the number of retention classes, log sources and environments rather than from the policy logic itself.

DriverWhy it changes effortHow to keep it down
Log sources and index patternsEach source or index pattern needs its own rollover conditions, naming, and mapping checks, so policy count and testing grow with every new feed.Group sources that share a retention and rollover profile, and confirm the source inventory in writing before the design starts.
Distinct retention classesEach class needs its own delete or move timing, legal hold handling, and evidence that the timing works in practice.Limit classes to the retention periods your policy actually requires, and map every index pattern to one of them.
Hot, warm, or cold tiers on separate hardware or node attributesTier moves need node attributes, allocation rules, and capacity planning for each tier, and they add a second place where data can fail to move.Start with one tier if the workload allows it, and confirm with your platform team which node types already exist before adding tiers.
Number of environments using the same policiesEach environment needs its own validation run, and differences between dev, test, and production configuration cause rework.Define one policy template library and promote it through environments as code, with only documented variables changing.
Custom ingest pipelines or naming conventionsRollover uses index aliases and naming patterns, so non-standard names or pipelines that write to fixed indices break automated rollover.Agree naming standards and alias conventions before go-live, and ask for any ingest pipeline that sets index names to be listed up front.
Snapshot repository and storage setupRetention deletes and tier moves depend on a working snapshot repository, its access rights, and its storage capacity, which must be built and tested first.Confirm the repository location, credentials, and storage quota with your infrastructure team, and reuse an existing repository if it meets policy.
Compliance evidence requirementsAssessors may ask for proof of retention periods, deletion records, and change history, which means extra reports, logs, and documented test runs.Agree the evidence list with your compliance lead before design, so the same reports serve both the audit and operations.
Existing snapshot practiceTeams that already run snapshots and restore tests need less new design work, while teams starting from scratch need repository, schedule, and restore testing built together.Ask whether snapshot schedules and restore tests already exist and whether they cover the indices in scope.

How to control who can change retention and delete data

Lifecycle policies can delete data for an entire cluster in one run, so who can write, attach and remove them matters as much as the policies themselves. The cards below cover the roles, credentials and logs that decide who can change retention and who can delete indices.

Restrict ISM APIs to a small admin role

Index State Management exposes its policy and management APIs to any user whose role grants them. Limit those permissions to a small named admin role, and confirm in your version's Security plugin documentation which cluster and index permissions gate each ISM action. Test the role with a non-admin account before go-live, since a permission that looks narrow can still allow policy changes.

Separate policy authors from index deleters

Keep the role that writes or edits lifecycle policies apart from the role that can delete indices. A platform engineer may draft a retention policy, while a separate approver or the admin role applies it. This split means one compromised or careless account cannot both change the rule and remove the data it governs.

Protect snapshot repository credentials

Snapshot repositories store the copies that keep data recoverable after a deletion, so their credentials and bucket or file-system permissions need the same protection as production data. Store repository keys in the OpenSearch keystore, grant the cluster only the write and list access it needs, and confirm whether delete rights on the repository are required for your retention design.

Keep delete actions out of wildcard roles

Broad roles that match index patterns such as star or logs-star can grant delete rights over indices nobody meant to expose. Review every role for cluster and index permissions that include delete, and remove wildcard matches that reach indices managed by lifecycle policies. Record the reason each delete grant exists so reviewers can challenge it.

Record policy changes in audit logs

The Security plugin provides audit logs that can record authentication and access events, which helps show who changed a lifecycle policy or attached it to an index. Decide which categories to enable, where logs are forwarded, and how long they are kept, and confirm with your version's documentation exactly which ISM events they capture. Without this record, retention changes are hard to trace after an incident.

Review lifecycle permissions on a schedule

Roles drift as teams change, so set a recurring review of who holds ISM, snapshot and delete permissions. Compare the role list against the people and service accounts that still need them, and remove stale mappings from identity provider groups. Document the review owner and the date of each review so auditors can see the control operating over time.

How to prove retention works and fails safely

A retention policy is only trustworthy after someone has tried to break it. Before you rely on Index State Management to roll over, shrink, move and delete indices, run a staged test that confirms each index picks up the intended policy, that every state transition does what the policy says, and that a failure stops the delete instead of letting it run. Treat this as an acceptance test for the lifecycle design, and keep the results as evidence for the retention owner and any later compliance review. Start with policy attachment. Create a test index that matches each index pattern in your index templates and confirm it receives the expected policy ID, using the explain view for each index. Then add a deliberately non-matching index, such as one created by a script that skips the template, and confirm it shows no policy. That second check matters because the most common silent failure is an index that misses a template and never gets a policy, so it is never rolled over, moved or deleted. Build a report that lists every index without a policy and schedule it to run after each deployment. Next, exercise the transitions in staging with a copy of production-shaped data. Force a rollover and confirm the new write index exists, the alias points to it, and document counts add up across the old and new indices. Run a shrink and check the target shard count, the document count against the source, and that the source is closed or removed as the policy specifies. Then move an index to a lower-cost tier, if you use one, and run a query against it. A moved index that stops serving queries is an availability defect, not a storage success. The failure tests answer the question of whether a policy fails safely. Create a policy whose state never advances, for example by pointing a transition at a condition that cannot be met, and confirm that alerting on a stalled state fires before anyone assumes the data is aging out. Next, configure a delete action that runs before a snapshot succeeds, then simulate a failed snapshot by making the repository unreachable, and check whether the delete still happens. In a well-designed policy, data should not be removed while the backup it depends on is missing. Finally, fill the disk on a test data node, or simulate it with the vendor's disk watermark settings, and observe whether delete actions still run and whether the cluster blocks writes as expected. Finally, prove recovery, not just deletion. Restore a snapshot of an index that has already passed its delete age into an isolated cluster, confirm the document count and a sample of queries match expectations, and record how long the restore took on your hardware. Confirm the time window your retention requirement allows for recovery, and write down the people who approve a restore. Ask your implementation partner to deliver these test cases as scripts with pass and fail criteria, so the tests can be rerun after every OpenSearch minor upgrade.

Questions teams ask before they build OpenSearch retention

What drives the cost of setting up OpenSearch lifecycle policies?

The cost depends mostly on how many retention rules you need and how many data streams, index patterns and tenants they touch. A single time-based delete rule on one index pattern is a small job. Retention that differs by log source, by compliance class or by tier (hot, warm, cold, delete) multiplies the design, testing and review work. Other drivers include how much existing data must be re-indexed or re-policied, how many environments need the same policies, and whether snapshot repositories must be built and tested alongside the policies. Ask a partner to price each policy group separately in the written scope, and to name which parts are one-time (design, build, verification, handover) and which recur (rule changes, reviews, upgrades).

How long does OpenSearch index lifecycle work usually take?

Duration depends on the number of retention rules, the state of your current indices and how many teams must approve the rules. Work that is mostly configuration on a clean cluster goes quickly. Work that needs an inventory of existing indices, agreement from data owners on retention periods, and tests of rollover and deletion on realistic data takes longer. Cluster size and the number of environments also matter because each one needs verification. No timeline is fixed here. Ask for the schedule as milestones in the written scope, with the dependencies on retention owners and snapshot storage listed separately so delays can be traced.

What does our internal team need to provide for lifecycle work?

Three roles usually carry the work. Retention owners define how long each data class must be kept, who may read it and when it must be deleted, and they sign off on the rules. Cluster administrators provide access, review changes to index state management policies and own the day-to-day operation. Snapshot storage owners provide a repository that the cluster can write to, with its own retention and access controls. If any of these roles is missing, the lifecycle policies may be technically correct but unapproved. Confirm named people for each role before the scope is signed.

Can our team set up OpenSearch retention without outside help?

Yes, if your team already runs OpenSearch and has someone comfortable with its index state management APIs, snapshots and the Security plugin roles that control who can change policies. OpenSearch is released under the Apache License, Version 2.0, so the software itself carries no license fee. The harder parts are usually the retention decisions, testing deletes safely, and proving to auditors that the rules match policy. A partner can help with any of these, or supply a written scope that your team executes. Decide which parts you will own and which you want reviewed.

How do lifecycle policies interact with OpenSearch upgrades?

Policies and indices must stay compatible across the upgrade path, so lifecycle rules should be reviewed before any version change. OpenSearch documents rolling upgrades, snapshot and restore, remote reindexing and Migration Assistant as upgrade and migration methods, and each one handles existing indices and snapshots differently. Snapshots taken on one version must be restorable on the target version, and policy actions that change during an upgrade need re-testing. OpenSearch versions also move through maintenance, with patches but no new features, so plan retention work around the minor release cadence and the end-of-life dates published on the releases page.

What should we ask a partner to include in a written OpenSearch retention scope?

Ask for an inventory of data streams and index patterns, a list of retention classes with the owner who approved each period, and the lifecycle states each class moves through (rollover, shrink, move, delete). The scope should name the snapshot repository, its retention and access controls, and how deletes are tested before they run in production. Request the verification plan, the handover material for cluster administrators, and the list of what is one-time versus recurring. Also ask how changes to retention will be reviewed, how upgrades will be planned, and which items depend on your team so that delays are visible in the schedule.

What breaks most often in OpenSearch retention setups?

The most common failures are policies that never match the indices they were meant for, rollover conditions that never trigger because of how write aliases were set up, and deletes that run earlier than retention owners expect. Snapshots can also fail silently if the repository is full or access was revoked, which leaves data with no recovery point before it is removed. Check each policy against real index names, confirm that rollover aliases point where expected, and monitor policy execution and snapshot status. Test each delete path on non-production data before enabling it, and keep a record of who approved every retention period.

What to monitor, back up and document after go-live

The first weeks after go-live show whether the lifecycle design holds. Index State Management runs each policy against the indices attached to it, so the operating team needs a standing check on managed indices instead of waiting for a storage alert. Use the explain view to see each index's current state, the action in progress and any failed step. Indices that sit in one state longer than the design expects usually point to a rollover condition that never triggers, a missing alias, or an allocation problem blocking a move between tiers. Alert on failed actions and on indices that stop advancing. Track total index size and shard count per tier each week, because shard counts that drift upward often signal template or rollover settings that no longer match the data volume.

Snapshots are the restore path for anything the policies delete or move, so confirm they succeed on the schedule the retention matrix assumes. Snapshot management policies create and expire snapshots on a timetable, and each run should be checked for success, partial results and repository errors. Watch repository free space and the age of the newest successful snapshot for each index pattern. Snapshot expiry should match retention classes, because a snapshot kept longer than the matrix allows can hold data the business has agreed to delete. Schedule a restore test on a non-production cluster at a fixed interval, and record how long it took and any gaps, so the runbook reflects what actually happened.

Every change to a policy, index template or alias needs a review against the retention schedule before it reaches production. A policy edit does not always reach indices that are already attached, and a broad index pattern can pull in data that belongs to another retention class, so the reviewer should list which indices each change touches. Treat OpenSearch upgrades the same way. Minor releases arrive about every eight weeks, so apply each one to a copy of the cluster inside the maintenance window and retest the lifecycle policies. Create a test index, step it through every state, and confirm that snapshots and deletions run as written. Record the version tested and the results before approving the upgrade for production.

Four documents make the handover durable. The retention matrix lists each data class, its index pattern, its tier path, its retention period and the legal or business basis for that period. The policy and template inventory maps every ISM policy, index template and alias to the pattern it governs and to its version in source control. The snapshot and restore runbook covers repository setup, schedules, expiry rules, restore steps and the record of past tests. Finally, name an owner for each retention class, including who approves changes and who answers when a deletion is questioned. Confirm with legal, records and security teams which retention periods are binding before the matrix is signed, because the platform will enforce whatever the matrix says.

How DeployOpen scopes, builds and hands over OpenSearch lifecycle work

DeployOpen approaches OpenSearch index lifecycle and data retention as a written, fixed-scope engagement inside your own infrastructure. We map retention requirements to index state policies, build and test them against your data streams, and hand over documented runbooks your team can operate. Ongoing support is available as a retainer.

How we scope

  • Inventory the indices, data streams and aliases that need lifecycle rules and their owners
  • Record retention periods and deletion rules from your policies and confirm them with the data owners
  • Agree the written scope, deliverables and timeline before any policy is changed on your cluster

How we build

  • Design Index State Management policies for rollover, shrink, move and delete stages per index pattern
  • Test each policy on a non-production copy of your cluster with representative index sizes and ages
  • Check that rollover conditions, snapshot timing and retention deletes behave as the written design states

How we hand over

  • Deliver a documented policy catalog listing each rule, its trigger, its owner and its retention purpose
  • Provide runbooks for failed policy steps, paused indices and manual override during incidents
  • Walk your operations and compliance staff through evidence of each retention control before close

How we support

  • Review lifecycle policies when retention requirements change or new index patterns are added
  • Re-test policies during OpenSearch minor and major upgrades inside the agreed maintenance window
  • Offer ongoing support as a retainer, with scope and response terms set out in writing

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.