﻿---
title: Customize data streams with namespace index templates
description: Enable namespace index templates so you can apply shared settings and mappings across a Fleet integration's data streams in one namespace.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/reference/fleet/data-streams-namespace-custom
products:
  - Elastic Agent
  - Fleet
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Planned
---

# Customize data streams with namespace index templates
Namespace index templates are Fleet-managed [index templates](/elastic/docs-content/pull/7705/manage-data/data-store/templates#index-templates) scoped to one namespace of an installed integration. When you opt a namespace in, Fleet creates one of these templates for each data stream defined by the integration, and each template references a `<namespace>@custom` component template that you create and manage.
Use this feature when you want the same custom settings or mappings on every data stream in a specific namespace for a given integration, instead of editing each data stream's `@custom` component template separately.

## How namespace index templates work

When you enable namespace index templates for a namespace on an installed integration, Fleet creates one namespace index template for each data stream defined by the integration. The templates are named using the following pattern:
```text
<type>-<dataset>@namespace.<namespace>
```

For example, enabling the `production` namespace for the System integration creates templates such as `logs-system.application@namespace.production`.
Each namespace index template is a copy of the integration's base data stream index template, but differs in these ways:
- The `index_patterns` value is scoped to that namespace (for example, `logs-system.application-production*`).
- The priority is the base template priority plus 50: `250` for most integrations (base `200`), or `200` for integrations with `dataset_is_prefix: true` data streams (base `150`). Because this is higher than the base template priority, Elasticsearch applies the namespace index template for matching data streams. If you change this priority manually, Fleet restores the default the next time the integration's templates are reinstalled or resynchronized.
- The `composed_of` list includes a `<namespace>@custom` component template (for example, `production@custom`) after the type-level and package-level `@custom` templates, and before the data stream-level `@custom` template.

Example `composed_of` list for `logs-system.application@namespace.production`:
```json
[
  "logs@mappings",
  "logs@settings",
  "logs-system.application@package",
  "logs@custom",
  "system@custom",
  "production@custom",
  "logs-system.application@custom",
  "ecs@mappings",
  ".fleet_globals-1",
  ".fleet_agent_id_verification-1"
]
```

Later component templates in this list take precedence when the same setting or mapping key appears more than once. From highest to lowest precedence among the `@custom` templates: `logs-system.application@custom`, then `production@custom`, then `system@custom`, then `logs@custom`.
<note>
  Fleet does not create the `<namespace>@custom` component template. You create and manage that template yourself. Until you create it, the reference in `composed_of` has no effect. The same `<namespace>@custom` template is shared by namespace name across every integration that has that namespace opted in.
</note>

The namespaces you opt in for an integration are the same across the whole cluster. The index templates and component templates Fleet creates are also shared across the cluster.
If your Kibana space restricts which namespaces are allowed, you can only enable namespace index templates for namespaces that match those restrictions.

## Enable namespace index templates in the UI

You can enable namespace index templates from the integration settings, or while creating or editing an integration policy.
<dropdown title="From the integration's Settings tab">
  1. Find **Integrations** in the navigation menu or use the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/explore-analyze/find-and-organize/find-apps-and-objects).
  2. Open the **Installed integrations** tab, then select the integration.
  3. Open the **Settings** tab.
  4. In the **Namespace index templates** section, add the namespace you want to customize.
  5. Save your changes.
</dropdown>

<dropdown title="From the integration policy editor">
  1. Find **Integrations** in the navigation menu or use the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/explore-analyze/find-and-organize/find-apps-and-objects).
  2. Select the integration you want, then create a new integration policy or select an existing integration policy from the **Integration policies** tab.
  3. In the **Integration settings** section, expand **Advanced options**.
  4. In the **Namespace** field, enter the namespace you want to customize.
  5. Turn on **Use dedicated index templates for this namespace**.
  6. Save the policy.
</dropdown>

After you save, Fleet creates the namespace index templates asynchronously. You can confirm they exist on the integration's **Assets** tab, or in the **Index Management** → **Index Templates** list by searching for `@namespace.`.
<important>
  Namespace index templates are shared across all integration policies for that integration and namespace. Enabling or turning them off for one policy updates the opt-in list for the entire integration.
</important>


## Create the namespace `@custom` component template

1. Find **Index Management** in the navigation menu or use the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/explore-analyze/find-and-organize/find-apps-and-objects), and open the **Component Templates** tab.
2. Select **Create component template**.
3. Name the template using the pattern `<namespace>@custom` (for example, `production@custom`).
4. Add the index settings, mappings, or aliases you want applied to every data stream in that namespace for opted-in integrations.
5. Create the component template.
6. Roll over each affected data stream so new backing indices pick up the changes. For example:
   ```json
   ```


## Enable namespace index templates with the API

You can also manage opt-in with the Fleet package APIs. Template create and delete operations run asynchronously after the request succeeds.
To enable one or more namespaces for a single installed package:
```json

{
  "namespace_customization_enabled_for": ["production"]
}
```

<note>
  For a single package, `namespace_customization_enabled_for` replaces the full opt-in list. To keep existing namespaces, include them in the array. To turn a namespace off, omit it from the array, or pass an empty array to clear the list.
</note>

To enable namespaces or remove them from the opt-in list across multiple packages in one request:
```json

{
  "packages": ["system", "nginx", "apache"],
  "enable": ["production"],
  "disable": ["staging"]
}
```

The bulk endpoint is additive and subtractive: `enable` adds namespaces to each package's opt-in list, and `disable` removes them. It does not replace the full list.

## Turn off namespace index templates

You can remove a namespace from the opt-in list in either of these ways:
- On the integration **Settings** tab, remove the namespace from **Namespaces with dedicated index templates**, then save.
- In the integration policy editor, turn off **Use dedicated index templates for this namespace**, then save.

When you remove a namespace from the opt-in list, Fleet deletes the corresponding namespace index templates. The `<namespace>@custom` component template is left in place so you can reuse it later.

## Overlapping index templates

If you previously duplicated a base data stream index template and gave the copy a higher priority, that copy can overlap with the Fleet-managed namespace index template. When you opt a namespace in, Fleet warns you about overlapping templates and what will happen for each one.
For details and resolution steps, refer to [Resolve overlapping index templates for namespace customization](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/reference/fleet/data-streams-template-conflicts).

## Related pages

- [Elastic Agent data streams for Fleet](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/reference/fleet/data-streams)
- [Edit the Elasticsearch index template](/elastic/docs-content/pull/7705/reference/fleet/data-streams#data-streams-index-templates-edit)
- [Resolve overlapping index templates for namespace customization](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7705/reference/fleet/data-streams-template-conflicts)