---
title: Tutorials: Customize data retention policies
description: These tutorials explain how to apply a custom ILM policy to an integration’s data stream. For certain features you’ll need to use a slightly different...
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/reference/fleet/data-streams-ilm-tutorial
products:
  - Elastic Agent
  - Fleet
---

# Tutorials: Customize data retention policies
These tutorials explain how to apply a custom ILM policy to an integration’s data stream.

## Before you begin

For certain features you’ll need to use a slightly different procedure to manage the index lifecycle:
- APM: For versions 8.15 and later, refer to [Index lifecycle management](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/solutions/observability/apm/index-lifecycle-management).
- Synthetic monitoring: Refer to [Manage data retention](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/solutions/observability/synthetics/manage-data-retention).
- Universal Profiling: Refer to [Universal Profiling index life cycle management](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/solutions/observability/infra-and-hosts/universal-profiling-index-life-cycle-management).


## Identify your scenario

How you apply an ILM policy depends on your use case. Choose a scenario for the detailed steps.
- **[Scenario 1](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/reference/fleet/data-streams-scenario1)**: You want to apply an ILM policy to all logs or metrics data streams across all namespaces.
- **[Scenario 2](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/reference/fleet/data-streams-scenario2)**: You want to apply an ILM policy to selected data streams in an integration.
- **[Scenario 3](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/reference/fleet/data-streams-scenario3)**: You want to apply an ILM policy for data streams in a selected namespace in an integration.
- **[Scenario 4](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4236/reference/fleet/data-streams-scenario4)**: You want to apply an ILM policy to all data streams in a custom integration using a `@custom` component template. `stack: ga 9.1`