# How to define routing allocation of apm server index template

**URL:** <https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244>\
**Category:** APM\
**Tags:** ilm-index-lifecycle-management, server\
**Created:** [June 5, 2023, 3:56pm UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244 "2023-06-05T15:56:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kay\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_khan/32/45028_2.png) [@Kay\_Khan](https://discuss.elastic.co/u/Kay_Khan)\
**Post date:** [June 5, 2023, 3:56pm UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/1 "2023-06-05T15:56:42Z")

</div>

We would like to define the routing allocation of all index templates created by the apm server so that they are stored on our dedicated nodeset group "monitoring"

This is what we have attempted but unfortunately we find that the data gets stored on nodes other than the ones where the attri is "monitoring"

```auto
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
  name: apm-server-prod
  namespace: elastic-system
spec:
  version: 8.7.1
  count: 1
  elasticsearchRef:
    name: "elasticsearch-prod"
  kibanaRef:
    name: "kibana-prod"
  http:
    service:
      spec:
        type: NodePort
  podTemplate:
    spec:
      containers:
      - name: apm-server
  config:
    http.enabled: true
    http.port: 5068
    monitoring.enabled: false
    setup.template.settings:
      index:
        routing.allocation.require.type: "monitoring"
        anonymous:
          rate_limit:
            event_limit: 300
            ip_limit: 1000
          allow_service: ["admin-dashboard", "frontend"]
    apm-server.rum.enabled: true
    apm-server.rum.allow_origins: ["*"]
    apm-server:
      template.settings:
        index:
          routing.allocation.require.type: "monitoring"

```

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [June 6, 2023, 5:56am UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/2 "2023-06-06T05:56:08Z")

</div>

The `apm-server.template.*` settings are not available anymore in `8.x`, as the asset setup (index templates, component templates, ILM policies, etc.) moved to Kibana. Having multiple apm-servers with conflicting index setup configurations has caused problems in the past, therefore the setup is now centralized.  
The templates are set up when [installing the APM Integration](https://www.elastic.co/guide/en/apm/guide/current/apm-server-configuration.html#_install_the_apm_integration). Once installed, `@custom` component templates available, where you can customize your settings.

---

<div class="post-metadata">

**Author:** ![Kay\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_khan/32/45028_2.png) [@Kay\_Khan](https://discuss.elastic.co/u/Kay_Khan)\
**Post date:** [June 6, 2023, 7:21am UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/3 "2023-06-06T07:21:34Z")

</div>

I'm sorry i dont quite understand, Am i right in thinking this needs to be done via Kibana config?

This is what my kibana config looks like

```auto
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana-prod
  namespace: elastic-system
spec:
  version: 8.7.1
  count: 1
  elasticsearchRef:
    name: elasticsearch-prod
  http:
    service:
      spec:
        type: NodePort
  podTemplate:
    metadata:
      labels:
        scrape: kb
    spec:
      containers:
      - name: kibana
        resources:
          limits:
            memory: 4Gi
            cpu: 2
      nodeSelector:
        geeiq/node-type: ops
  config:
    monitoring.kibana.collection.enabled: false
    xpack.fleet.packages:
      - name: apm
        version: latest

```

Where should i be defining the

```auto
 apm-server:
      template.settings:
        index:
          routing.allocation.require.type: "monitoring"

```

Or where can i define the routing for these @custom templates in my yaml?

Also note the link you provided leads to an integration method for apm which i dont believe i'm using. Is this a problem, i'm quite confused at this point. As far as i understand my integration method is by defining. Taken from [cloud-on-k8s/apm\_es\_kibana.yaml at main · elastic/cloud-on-k8s · GitHub](https://github.com/elastic/cloud-on-k8s/blob/main/config/samples/apm/apm_es_kibana.yaml)

```auto
    xpack.fleet.packages:
      - name: apm
        version: latest

```

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [June 6, 2023, 4:01pm UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/4 "2023-06-06T16:01:37Z")

</div>

> I'm sorry i dont quite understand, Am i right in thinking this needs to be done via Kibana config?

No unfortunately this can't be achieved via configuration. You can configure the custom component template via ES API calls.

> Also note the link you provided leads to an integration method for apm which i dont believe i'm using. Is this a problem, i'm quite confused at this point.

The way you install the apm integration via kibana config is totally fine.

---

<div class="post-metadata">

**Author:** ![Kay\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_khan/32/45028_2.png) [@Kay\_Khan](https://discuss.elastic.co/u/Kay_Khan)\
**Post date:** [June 7, 2023, 7:36am UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/5 "2023-06-07T07:36:58Z")

</div>

Okay thanks for confirming its no longer possible to codify these changes in our apm-server.yaml.

We have been following a standard when installing any elastic component and its a shame that we can't do this when it comes to the apm-server.

e.g filebeat and metricbeat look similar.

```auto
...
  config:
    setup.template.settings:
      index:
        routing.allocation.require.type: "monitoring"

```

* * *

We understand although we hope that you would take into consideration of allowing users to define the routing allocation via some .yaml configuration, so that we can codify the changes.

For now we have documented these api calls (which we will have to replicate for every apm component). Is there a section in the github that you can point us to do that we can refer to to see all the latest components ?

```auto
PUT _ilm/policy/apm-custom
{
  "policy": {
    "phases": {
      "hot": {
        "actions": { 
          "rollover": {
            "max_age": "30d",
            "max_size": "50GB",
            "max_primary_shard_size": "50gb"
            
          }
        }
      }
    }
  }
}

PUT _component_template/traces-apm.rum@custom
{
  "template": {
    "settings": {
      "routing": {
        "allocation": {
          "require": {
            "type": "monitoring"
          }
        }
      }, 
      "lifecycle": {
        "name": "apm-custom"
      }
    }
  }
}

GET _component_template/traces-apm.rum@custom

```

Although untested as we have seen that our datastream uses the \*default\_policy as opposed to the custom one. Do you know why that is?

![image](https://us1.discourse-cdn.com/elastic/original/3X/6/0/60df92d4ff7561dc02c35f23303624a93d2da42f.png)

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [June 7, 2023, 10:55am UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/6 "2023-06-07T10:55:30Z")

</div>

Thanks for the feedback. We are having some internal discussions how we can improve the setup.

As for your concrete problem - please try a rollover on the datastream after changing the `@custom` component `POST traces-apm.rum-default/_rollover`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2023, 10:55am UTC](https://discuss.elastic.co/t/how-to-define-routing-allocation-of-apm-server-index-template/335244/7 "2023-07-05T10:55:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
