# Metricbeat - how to create two different index templates from me metricbeat.yml

**URL:** https://discuss.elastic.co/t/metricbeat-how-to-create-two-different-index-templates-from-me-metricbeat-yml/338298
**Category:** Beats
**Tags:** metricbeat
**Created:** [July 13, 2023, 9:01am UTC](https://discuss.elastic.co/t/metricbeat-how-to-create-two-different-index-templates-from-me-metricbeat-yml/338298 "2023-07-13T09:01:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Terkea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/terkea/32/122058_2.png) [@Terkea](https://discuss.elastic.co/u/Terkea)
#### Post date: [July 13, 2023, 9:01am UTC](https://discuss.elastic.co/t/metricbeat-how-to-create-two-different-index-templates-from-me-metricbeat-yml/338298/1 "2023-07-13T09:01:53Z")

</div>

Hello guys,

I want to create two different index templates with different ILM policies for each module that I use in metricbeat.

My `metricbeat.yml`

```yml
metricbeat:
  modules:
  - hosts:
    - http://localhost:5067
    metricsets:
    - stats
    - state
    module: beat
    period: 10s
    setup.template.enabled: true
    setup.template.name: template_metricbeat-ov2-staging-microservices-beat
    setup.template.pattern: metricbeat-ov2-staging-microservices-beat-*
    setup.template.settings:
      index.lifecycle.name: data_retention_7_days
      index.lifecycle.rollover_alias: metricbeat-ov2-staging-microservices-beat
  - cpu_ticks: false
    metricsets:
    - cpu
    - filesystem
    - network
    - process
    module: system
    period: 10s
    processes:
    - .*
    setup.template.enabled: true
    setup.template.name: template_metricbeat-ov2-staging-microservices-system
    setup.template.pattern: metricbeat-ov2-staging-microservices-system-*
    setup.template.settings:
      index.lifecycle.name: data_retention_30_days
      index.lifecycle.rollover_alias: metricbeat-ov2-staging-microservices-system

###############################################################################
############################# Libbeat Config ##################################
# Base config file used by all other beats for using libbeat features

############################# Output ##########################################

output:
  elasticsearch:
    hosts:
    - ''
    indices:
    - index: metricbeat-ov2-staging-microservices-beat-%{[agent.version]}-%{+yyyy.MM.dd}
      when.contains:
        event.module: beat
    - index: metricbeat-ov2-staging-microservices-system-%{[agent.version]}-%{+yyyy.MM.dd}
      when.contains:
        event.module: system

############################# Logging #########################################

logging:
  files:
    rotateeverybytes: 104857600

```

The issue that I have is that none of the defined index templates gets created. I am not entirely sure if I am allowed to do under the modules.

```yml
    setup.template.enabled: true
    setup.template.name: template_metricbeat-ov2-staging-microservices-beat
    setup.template.pattern: metricbeat-ov2-staging-microservices-beat-*
    setup.template.settings:
      index.lifecycle.name: data_retention_7_days
      index.lifecycle.rollover_alias: metricbeat-ov2-staging-microservices-beat

```

At the moment both index templates are ignored and metricbeat creates the metricbeat-8.8.2 index template.

Ultimately, my question is how can one create two different index templates from the `metricbeat.yml` as I want different lifecycle policies attached to each template.

---

<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: [August 10, 2023, 11:02am UTC](https://discuss.elastic.co/t/metricbeat-how-to-create-two-different-index-templates-from-me-metricbeat-yml/338298/2 "2023-08-10T11:02:21Z")

</div>

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