|
| 1 | +--- |
| 2 | +navigation_title: Scenario 4 |
| 3 | +mapped_pages: |
| 4 | + - https://www.elastic.co/guide/en/fleet/current/data-streams-scenario4.html |
| 5 | +products: |
| 6 | + - id: fleet |
| 7 | + - id: elastic-agent |
| 8 | +--- |
| 9 | + |
| 10 | +# Scenario 4: Apply an ILM policy to all data streams in a custom integration [data-streams-scenario4] |
| 11 | + |
| 12 | +If you’ve created a custom integration package, you can apply a single ILM policy to all its data streams using a shared `@custom` component template. This eliminates the need to configure each data stream individually. |
| 13 | + |
| 14 | +:::{note} |
| 15 | +This method is available in version 9.1 and later. |
| 16 | +::: |
| 17 | + |
| 18 | +## Step 1: Define the ILM policy [data-streams-scenario4-step1] |
| 19 | + |
| 20 | +1. In {{kib}}, go to **Stack Management** and select **Index Lifecycle Policies**. You can also use the [global search field](/get-started/the-stack.md#kibana-navigation-search). |
| 21 | +2. Click **Create policy**. |
| 22 | +3. Name the policy, configure it as needed, and click **Save policy**. |
| 23 | + |
| 24 | +## Step 2: Create a custom component template [data-streams-scenario4-step2] |
| 25 | + |
| 26 | +Create a custom component template named `<integration>@custom`, replacing `<integration>` with your package name. |
| 27 | + |
| 28 | +For example, for a Docker integration, use: |
| 29 | + |
| 30 | +```json |
| 31 | +PUT _component_template/docker@custom |
| 32 | +{ |
| 33 | + "template": { |
| 34 | + "settings": { |
| 35 | + "index": { |
| 36 | + "lifecycle": { |
| 37 | + "name": "docker-ilm-policy" |
| 38 | + } |
| 39 | + } |
| 40 | + }, |
| 41 | + "mappings": { |
| 42 | + "properties": { |
| 43 | + "@timestamp": { |
| 44 | + "type": "date" |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +## Step 3: Deploy or update the integration [data-streams-scenario4-step3] |
| 53 | + |
| 54 | +The `@custom` component template is automatically included when the package is installed or updated. |
| 55 | + |
| 56 | +To apply the ILM policy: |
| 57 | + |
| 58 | +- Bump the version of your custom package. |
| 59 | + |
| 60 | +- Reinstall or upgrade the package using the Fleet UI or Developer Console. |
| 61 | + |
| 62 | +After it has been deployed, the ILM policy from `docker@custom` will apply to all data streams in the package. |
0 commit comments