﻿---
title: Customize data retention policies for integrations
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://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-ilm-tutorial
products:
  - Elastic Agent
  - Fleet
applies_to:
  - Elastic Cloud Serverless: Unavailable
  - Elastic Stack: Generally available
---

# Customize data retention policies for integrations
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://www.elastic.co/elastic/docs-builder/docs/3895/solutions/observability/apm/index-lifecycle-management).
- Synthetic monitoring: Refer to [Manage data retention](https://www.elastic.co/elastic/docs-builder/docs/3895/solutions/observability/synthetics/manage-data-retention).
- Universal Profiling: Refer to [Universal Profiling index life cycle management](https://www.elastic.co/elastic/docs-builder/docs/3895/solutions/observability/infra-and-hosts/universal-profiling-index-life-cycle-management).


## Identify your use case

How you apply an ILM policy depends on the data streams you want it to cover. Choose the approach that matches your use case.
- **[Apply an ILM policy to all data streams across all namespaces](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-scenario1)**: Edit the `logs@custom` or `metrics@custom` component template, so the policy covers every Fleet `logs-*` or `metrics-*` data stream. Repeat separately for logs and for metrics.
- **[Apply an ILM policy to specific data streams across all namespaces](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-scenario2)**: Edit a data stream's own `@custom` component template, leaving the integration's other data streams untouched.
- **[Apply an ILM policy to one data stream in one namespace](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-scenario3)**: Clone the integration's index template and scope the copy to a single namespace. This is the heaviest option, because you take on maintaining the cloned template.
  <applies-to>Elastic Stack: Generally available since 9.5</applies-to> For shared settings across every data stream in a namespace, refer to [Customize data streams with namespace index templates](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-namespace-custom).
- <applies-to>Elastic Stack: Generally available since 9.1</applies-to> **[Apply an ILM policy to all data streams in a custom integration](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-scenario4)**: Create an `<integration>@custom` component template for an integration package you built yourself.

<note applies-to="Elastic Stack: Generally available since 9.5">
  To apply an ILM policy to every data stream an integration produces in a single namespace, without editing templates yourself, refer to [Apply an ILM policy to an integration namespace](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-namespace-ilm). This option requires [namespace index templates](https://www.elastic.co/elastic/docs-builder/docs/3895/reference/fleet/data-streams-namespace-custom).
</note>