View the Elasticsearch index templateedit

Index templates are used to configure the backing indices of data streams as they are created. These index templates are composed of multiple component templates—​reusable building blocks that configure index mappings, settings, and aliases.

The default APM index templates can be viewed in Kibana. Navigate to Stack Management > Index Management > Index Templates, and search for apm. Select any of the APM index templates to view their relevant component templates.

Edit the Elasticsearch index templateedit

Custom index mappings may conflict with the mappings defined by the APM integration and may break the APM integration and APM app in Kibana. Do not change or customize any default mappings.

When you install the APM integration, Fleet creates a default @custom component template for each data stream. You can edit this @custom component template to customize your Elasticsearch indices.

First, determine which data stream you’d like to edit. Then, open Kibana and navigate to Stack Management > Index Management > Component Templates.

Custom component templates are named following this pattern: <name_of_data_stream>@custom. Search for the name of the data stream, like traces-apm, and select its custom component template. In this example, that’d be, traces-apm@custom. Then click Manage > Edit.

Add any custom index settings, metadata, or mappings. For example, you may want to…​

  • Customize the index lifecycle policy applied to a data stream. See custom index lifecycle policies for a walk-through.
  • Change the number of shards per index. Specify the number of primary shards in the index settings:

    {
      "settings": {
        "number_of_shards": "4",
      }
    }
  • Change the number of replicas per index. Specify the number of replica shards in the index settings:

    {
      "index": {
        "number_of_replicas": "2"
      }
    }

Changes to component templates are not applied retroactively to existing indices. For changes to take effect, you must create a new write index for the data stream. This can be done with the Elasticsearch Rollover API. For example, to roll over the traces-apm-default data stream, run:

POST /traces-apm-default/_rollover/