# Metricbeat and Heartbeat 8.x custom index Name should pickup from template ,but creates always bedefault index name

**URL:** https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557
**Category:** Beats
**Tags:** metricbeat
**Created:** [July 4, 2023, 12:11pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557 "2023-07-04T12:11:41Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 4, 2023, 12:11pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/1 "2023-07-04T12:11:41Z")

</div>

Hello All,

I'm migrating metricbeat and heartbeat from 7.9.1 to 8.7.1 version and current challenge is I'm unbale to create custom index name defined in my index template and metricbeat.yml.  
I'm not sure how come everytime a default index by metricbeat is getting created,requirement is to have my own index name.

This is the output not required(8.7.1):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/6/466251868f872ac38024b767a697d1a0f81e6a25.png)

The index that should be shown up is,this was achieved in 7.9.1 using below configs and need same in 8.7.1:  
**cis-metric-2023.07.04-000001**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/c/dcca56f842415a85b8a6261a659f05eaa0796eee.png)

metricbeat.yml:

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["abc:443"]
  ssl.certificate_authorities: ["/l/ppp/mis/config/ece_proxy_root_ca.pem"]
  protocol: "https"
  username: "b"
  password: "b"
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event
monitoring.enabled: true
monitoring.elasticsearch: null

```

template:

```auto
PUT _index_template/cis-metric
{
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "cis-monitoring-common-policy",
          "rollover_alias": "cis-metric"
        },
        "number_of_shards": "1",
        "number_of_replicas": "0"
      }
    },
    "mappings": {
      "_routing": {
        "required": false
      },
      "numeric_detection": false,
      "dynamic_date_formats": [
        "strict_date_optional_time",
        "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
      ],
      "_source": {
        "excludes": [],
        "includes": [],
        "enabled": true
      },
      "dynamic": true,
      "date_detection": true,
      "properties": {
        "system.cpu.iowait.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.rss.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.write.bytes": {
          "type": "long"
        },
        "system.load.cores": {
          "type": "long"
        },
        "system.process.cpu.total.value": {
          "type": "long"
        },
        "service.type": {
          "type": "keyword"
        },
        "system.diskio.iostat.service_time": {
          "type": "float"
        }
      }
    }
  },
  "index_patterns": [
    "cis-metric-*"
  ],
  "composed_of": []
}

```

Any suggestion would be helpful.

---

<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 4, 2023, 12:11pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/2 "2023-07-04T12:11:41Z")

</div>

7.9.1 is [EOL](https://www.elastic.co/support/eol) and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 4, 2023, 1:47pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/3 "2023-07-04T13:47:42Z")

</div>

Hi @PRASHANT_MEHTA Not sure why the above was working for 7.9 ... seems like you never named the index in the output section so I would expect the index to be the default name.

Anyways...

Here is a working version for 8.x/8.7/8.8 etc

This sets up a template, data stream, index lifecycle policy, and backing indices etc

run `setup` first

You could even setup the dashboards to work with this if you want...

```auto
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}" # <!---- Don't add -%{+yyyy.MM.dd} its a data strean and getts added to the backing index automatically
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false

setup.template.enabled: true # <!--- You should explicitly set this 
setup.template.name: "cis-metric-%{[agent.version]}" # <!----This needs to match the index name because now it is a data stream
setup.template.pattern: "cis-metric-%{[agent.version]}" # <!-- Better matching Hygiene because it is a data stream 
setup.template.overwrite: false # <!--- Careful with this if set to true it will overwrite every time.
setup.ilm.policy_name: cis-metric
# setup.dashboards.enabled: true # Uncomment this during setup if you want to load the dashboard to work with this data stream. 

```

 ![Screenshot 2023-07-04 at 6.36.33 AM](https://us1.discourse-cdn.com/elastic/original/3X/e/e/eec4568e7f1adadb45e61e37938df46a1d0dadef.png)

 ![Screenshot 2023-07-04 at 6.42.46 AM](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc8870185d38fe6882ee47c8db33948dd734b149.png)

 ![Screenshot 2023-07-04 at 6.38.12 AM](https://us1.discourse-cdn.com/elastic/original/3X/8/0/80ab8618e44e82868bab950b30cddfbf041fca48.png)

 ![Screenshot 2023-07-04 at 6.43.59 AM](https://us1.discourse-cdn.com/elastic/original/3X/e/7/e751c795e2f3a1c4abcec065f580f1feb5b20404.png)

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 5, 2023, 9:22am UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/4 "2023-07-05T09:22:10Z")

</div>

Hello @stephenb ,

Thanx for your time to look into this and assisting on this.  
I did same setting as yours but still the data is not coming in index.  
If you will see above my custom template name is: PUT \_index\_template/cis-metric, do I need to do this PUT \_index\_template/cis-metric-8.7.1(this also didn't help)

My index is getting created like yours but data(docs) is not coming. I m still also getting by default metricbeat index getting created.  
I'd require metricbeat data to be mapped with my own custom template shared above.Not sure what is wrong .

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1e9eacb0b0b3a58c7eda88774a1300789a695496.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/7/676642957d9966161b6211bddbbd1221b6ab14ce.png)

Index templates:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/3/d375a1a20e0a7e28b914e40674a815132f05a846.png)

Everytime metricbeats starts this index also comes up:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b552ddc09fe7d1e9e74f7ce1e1ba5882aa584ac4.png)

Below is my current metricbeat.yml and you can have look at template above: template name and index pattern extreme end,does template needs any change so that it metricbeat.yml understands to map my external template?

Can you also plz tell me if I dont want to use data stream and manage it in old way,how this can be done- cis-metric-date-000001.

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false
setup.template.enabled: true
setup.template.name: "cis-metric-%{[agent.version]}"
setup.template.pattern: "cis-metric-%{[agent.version]}"
setup.template.overwrite: false
setup.ilm.policy_name: cis-metric-policy
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["https://abc:443"]
  index: "cis-metric-%{[agent.version]}"
  ssl.certificate_authorities: ["/l/ppp/cis/config/ece_atr_root_ca.pem"]
  protocol: "abc"
  username: "abc"
  password: "abc"
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event
monitoring.enabled: true
monitoring.elasticsearch: null

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 5, 2023, 1:27pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/5 "2023-07-05T13:27:49Z")

</div>

EDIT

start in the foreground with this and look at the docs that are being published

`filebeat -e -d "*"`

Also, are there any errors in the logs?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 5, 2023, 1:34pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/6 "2023-07-05T13:34:01Z")

</div>

> [@PRASHANT\_MEHTA](#):
>
> ```auto
> monitoring.enabled: true
> monitoring.elasticsearch: null
> 
> ```

That is why you have the .monitoring... Index

Set to `false` to turn it off or take out both those lines

I don't think you're writing any data at all.

Do you have the `modules.d/system.yml` enabled

It is not clear to me if the 2 templates are colliding...

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 5, 2023, 2:27pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/7 "2023-07-05T14:27:41Z")

</div>

Hello,

The data is available and now I can see in index,I tried with your method and still didn't got the data in index.I suppose the rollover thing is removed in 8.X version reading docs.  
Now I wrote new metricbeat.yml and my index is getting created and ilm is also applied.But after every 10 to 15 mins I'm getting this error:

**system.yml** was enabled and getting data now.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2e21cbaeea02940085f0514d69d4fa36d84121d1.png)

Updated metricbeat.yml

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
# setup.ilm.rollover_alias: cis-metric
# setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false
setup.template.enabled: true
setup.template.name: "cis-metric"
**setup.template.pattern: "cis-metric-*"**
setup.template.overwrite: false
setup.ilm.policy_name: cis-metric-policy
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["https://abc:443"]
  **index: "cis-metric-%{+yyyy.MM.dd}"**
  ssl.certificate_authorities: ["/l/app/ece_proxy_root_ca.pem"]
  protocol: ""
  username: ""
  password: ""
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event

```

In template if you will check earlier I shared,have removed rollover from it, as in 8.x its not supported I guess.

Removed this also:  
monitoring.enabled: true  
monitoring.elasticsearch: null

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 5, 2023, 2:37pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/8 "2023-07-05T14:37:34Z")

</div>

Again refreshed error is gone.Whats happening that sometimes it occurs 🤔

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a77077a7043c1aa37b1ffde2c5938953f2c5a922.png)

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 5, 2023, 2:38pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/9 "2023-07-05T14:38:25Z")

</div>

can you please try exactly my example

> [@PRASHANT\_MEHTA](#):
>
> ` **index: "cis-metric-%{+yyyy.MM.dd}"** `

Not correct that is what is causing the issue..

Can you please try _ **Exactly** _ my config just change the host and u/p.

```auto
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}" 
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false

setup.template.enabled: true  
setup.template.name: "cis-metric-%{[agent.version]}" 
setup.template.pattern: "cis-metric-%{[agent.version]}" 
setup.template.overwrite: false 
setup.ilm.policy_name: cis-metric

```

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 5, 2023, 3:17pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/10 "2023-07-05T15:17:40Z")

</div>

Applied the same config you provided.Below is how it looks like,but the docs in index are not coming. May I know if you are using your own custom template defined for mapping fields coming from metricbeat?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2edd66a061da5adb2bd839a5f7834b949c4247c9.png)

TWO TEMPLATES:  
cis-metric : I've committed in devtools-has my own mappings.  
cis-metric-8.7.1 creates automatically ,from metricbeat.yml

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

How demo templates looks like:

```auto
PUT _index_template/cis-metric
{
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "cis-metric-policy",
          "rollover_alias": "cis-metric"
        },
        "number_of_shards": "1",
        "number_of_replicas": "0"
      }
    },
    "mappings": {
      "_routing": {
        "required": false
      },
      "numeric_detection": false,
      "dynamic_date_formats": [
        "strict_date_optional_time",
        "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
      ],
      "_source": {
        "excludes": [],
        "includes": [],
        "enabled": true
      },
      "dynamic": true,
      "date_detection": true,
      "properties": {
        "system.cpu.iowait.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        }
      }
    }
  },
  "index_patterns": [
    "cis-metric-*"
  ],
  "composed_of": []
}

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 5, 2023, 3:31pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/11 "2023-07-05T15:31:04Z")

</div>

No I did not create a custom template metricbeat does it automatically... I think they are colliding or something...

Can you take your custom template out and try... clean up everything and try again...  
then we can work backwards to your custom template.

and I can see it is not the same because the policy name is wrong

Mine is this..  
`setup.ilm.policy_name: cis-metric`

Your shows : cis-metric-policy

Which means your template is being used... not the automatically generated template referenced with my configuration.

I suspect there is some mapping issue in your custom template vs the auto generated one...

Did you actually look at the logs or run in the foreground with the debug flags I showed you?

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 7, 2023, 8:38am UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/12 "2023-07-07T08:38:36Z")

</div>

Hello @stephenb ,

My bad,I did mistake in metricbeat.yml, your above config works fine and now I'm getting the data in my index.  
**Mistake done was added this** : index: "cis-metric-%{+yyyy.MM.dd}",removed and worked fine with your congigs now.Thanx for you efforts on this.

Few doubts if you could help me with this:

1)I was using 7.9.1 earlier and now migrating to 8.7.1 version. I'm facing challenges ,everything worked fine in 7.9.1 and now in 8.7.1 data stream came.I'm exploring and reading documentation but unable to implement or get the data in beats indices like I want.

I've around 50 indices i.e these are such that logstash process and send data to them and these documents are frequently updated. Through documentation understood DATA STREAM are not recommended for such data and only suitable only for time series data.Correct me if I am wrong.

2)Real challenge now: I want to use metricbeat,filebeat and heartbeat(all time series data) now with my own **CUSTOM templates** following my **own ILM policy defined**.  
I did this thing in 7.9.1 and worked everything well. Now in 8.7.1 what is the method and how to implement I'm not getting exactly after reading documentation.

Rollover are also not supported in 8.7.1 I guess? , and I use it in my template earlier.

Let me know how this can be done. Plz glance my Metric beat custom template and how data from beats could be mapped to custom templates?  
Ofcourse I tried everything from documentation ,with no luck of data stream getting created for custom template/policy,and not sure now to achieve this.Its work in progress for now.

CRUX: I would request to help out how to send data to respective indices following custom template and custom policy. Not using by default ones.  
For now with data streams seems confusing, rollover not supported ,then where could i define rollover alias type setting.  
I guess without using data streams also this could be done,but did'nt got relevant docs.

I dont think below are valid for 8.7.1 🤔

```auto
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'

```

Metricbeat Template:(removed rollover\_alias from settings in template,7.9.1 supported,8.7.1 dont support.

```auto
PUT _index_template/cis-metric
{
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "cis-metricbeat-policy"
        },
        "number_of_shards": "1",
        "number_of_replicas": "0"
      }
    },
    "mappings": {
      "_source": {
        "excludes": [],
        "includes": [],
        "enabled": true
      },
      "_routing": {
        "required": false
      },
      "dynamic": true,
      "numeric_detection": false,
      "date_detection": true,
      "dynamic_date_formats": [
        "strict_date_optional_time",
        "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
      ],
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "agent.id": {
          "type": "keyword"
        },
        "agent.name": {
          "type": "keyword"
        },
        "cpu.status": {
          "type": "keyword"
        },
        "host.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "metricset.name": {
          "type": "keyword"
        },
        "metricset.period": {
          "type": "long"
        },
        "mountpoint.details": {
          "type": "keyword"
        },
        "process.args": {
          "type": "keyword"
        },
        "process.details": {
          "type": "keyword"
        },
        "process.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "process.pgid": {
          "type": "long"
        },
        "process.pid": {
          "type": "long"
        },
        "process.ppid": {
          "type": "long"
        },
        "process.type": {
          "type": "keyword"
        },
        "service.type": {
          "type": "keyword"
        },
        "system.cpu.cores": {
          "type": "long"
        },
        "system.cpu.idle.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.idle.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.iowait.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.iowait.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.irq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.irq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.softirq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.softirq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.steal.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.steal.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.system.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.system.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.user.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.user.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.io.ops": {
          "type": "long"
        },
        "system.diskio.io.time": {
          "type": "long"
        },
        "system.diskio.iostat.await": {
          "type": "float"
        },
        "system.diskio.iostat.busy": {
          "type": "float"
        },
        "system.diskio.iostat.queue.avg_size": {
          "type": "float"
        },
        "system.diskio.iostat.read.await": {
          "type": "float"
        },
        "system.diskio.iostat.read.per_sec.bytes": {
          "type": "float"
        },
        "system.diskio.iostat.read.request.merges_per_sec": {
          "type": "float"
        },
        "system.diskio.iostat.read.request.per_sec": {
          "type": "float"
        },
        "system.diskio.iostat.request.avg_size": {
          "type": "float"
        },
        "system.diskio.iostat.service_time": {
          "type": "float"
        },
        "system.diskio.iostat.write.await": {
          "type": "float"
        },
        "system.diskio.iostat.write.per_sec.bytes": {
          "type": "float"
        },
        "system.diskio.iostat.write.request.merges_per_sec": {
          "type": "float"
        },
        "system.diskio.iostat.write.request.per_sec": {
          "type": "float"
        },
        "system.diskio.name": {
          "type": "keyword"
        },
        "system.diskio.read.bytes": {
          "type": "long"
        },
        "system.diskio.read.count": {
          "type": "long"
        },
        "system.diskio.read.time": {
          "type": "long"
        },
        "system.diskio.serial_number": {
          "type": "keyword"
        },
        "system.diskio.write.bytes": {
          "type": "long"
        },
        "system.diskio.write.count": {
          "type": "long"
        },
        "system.diskio.write.time": {
          "type": "long"
        },
        "system.diskspace.usage": {
          "type": "long"
        },
        "system.filesystem.used.pct": {
          "type": "float"
        },
        "system.fsstat.count": {
          "type": "long"
        },
        "system.fsstat.status": {
          "type": "keyword"
        },
        "system.fsstat.total_files": {
          "type": "long"
        },
        "system.fsstat.total_size.free": {
          "type": "long"
        },
        "system.fsstat.total_size.total": {
          "type": "long"
        },
        "system.fsstat.total_size.used": {
          "type": "long"
        },
        "system.load.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.load.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.load.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.load.cores": {
          "type": "long"
        },
        "system.load.norm.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.load.norm.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.load.norm.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.memory.actual.free": {
          "type": "long"
        },
        "system.memory.actual.used.bytes": {
          "type": "long"
        },
        "system.memory.actual.used.pct": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.memory.free": {
          "type": "long"
        },
        "system.memory.swap.free": {
          "type": "long"
        },
        "system.memory.swap.total": {
          "type": "long"
        },
        "system.memory.swap.used.bytes": {
          "type": "long"
        },
        "system.memory.swap.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.memory.total": {
          "type": "long"
        },
        "system.memory.used.bytes": {
          "type": "long"
        },
        "system.memory.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.network.in.bytes": {
          "type": "long"
        },
        "system.network.in.dropped": {
          "type": "long"
        },
        "system.network.in.errors": {
          "type": "long"
        },
        "system.network.in.packets": {
          "type": "long"
        },
        "system.network.name": {
          "type": "keyword"
        },
        "system.network.out.bytes": {
          "type": "long"
        },
        "system.network.out.dropped": {
          "type": "long"
        },
        "system.network.out.errors": {
          "type": "long"
        },
        "system.network.out.packets": {
          "type": "long"
        },
        "system.process.cpu.start_time": {
          "type": "date"
        },
        "system.process.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.cpu.total.value": {
          "type": "long"
        },
        "system.process.memory.rss.bytes": {
          "type": "long"
        },
        "system.process.memory.rss.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.share": {
          "type": "long"
        },
        "system.process.memory.size": {
          "type": "long"
        },
        "system.process.state": {
          "type": "keyword"
        },
        "user.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.process.cpu.total.ticks":
        {
          "type": "long"
        }
    }}
  },
  "index_patterns": [
    "cis-metric-*"
  ],
  "composed_of": []
}

```

system.yml(modules.d)

```auto
# Module: system
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.8/metricbeat-module-system.html
- module: system
  period: 30m
  metricsets:
    - memory
 
- module: system
  period: 10s
  metricsets:
    - load
    - network

- module: system
  period: 30m
  metricsets:
    - fsstat
    - filesystem
  filesystem.ignore_types: [ssysfs, rootfs, ramfs, bdev, cgroup, cpuset,debugfs, securityfs, sockfs, dax, bpf, pipefs, anon_inodefs, configfs, devpts, hugetlbfs, autofs, pstore, mqueue, selinuxfs, rpc_pipefs, binfmt_misc, overlay,nfs4,nfs,proc,sysfs]
  processors:
  - script:
        lang: javascript
        id: MountPointDataAdapter
        file: MountPointDataAdapter.js
        params:
            hostname: '${HOSTNAME}'
        
- module: system
  period: 10s
  metricsets:
    - diskio
  diskio.include_devices: ["sda", "sda1","vda","vda1"]
    
- module: system
  period: 5m
  metricsets:
    - process
  processes: ['.*']
  process.include_cpu_ticks: true
  processors:
  - script:
        lang: javascript
        id: ProcessDataUpdater
        file: ProcessDataUpdater.js
        params:
            hostname: '${HOSTNAME}'
  - script:
        lang: javascript
        id: process_args_filter
        file: process_args_filter.js
            
- module: system
  period: 30m
  metricsets:
    - cpu
  processors:
  - script:
        lang: javascript
        id: CPUStatusUpdater.js
        file: CPUStatusUpdater.js

```

Working metricbeat.yml for now:

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: cis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false
setup.template.enabled: true  
setup.template.name: "cis-metric-%{[agent.version]}" 
setup.template.pattern: "cis-metric-%{[agent.version]}" 
setup.template.overwrite: false 
setup.ilm.policy_name: cis-metric
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["abc:100"]
  ssl.certificate_authorities: ["/l/app/cis/monitoring/config/ece_proxy_root_ca.pem"]
  protocol: ""
  username: ""
  password: ""
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 8, 2023, 5:33pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/13 "2023-07-08T17:33:54Z")

</div>

> [@PRASHANT\_MEHTA](#):
>
> 2)Real challenge now: I want to use metricbeat,filebeat and heartbeat(all time series data) now with my own **CUSTOM templates** following my **own ILM policy defined**.

Did you simply try to replace the generated ILM Policy and Template with yours with the same names etc after you ran setup?

> [@PRASHANT\_MEHTA](#):
>
> Rollover are also not supported in 8.7.1 I guess? , and I use it in my template earlier.

Data streams rollover that is part of the core functionality... but you are right it is a bit different in 8.x Data Streams it is internal you do not use the write alias the Data Stream it IS the alias.

So what I did to test is I ran the setup with the config I had above.

Then you can just edit the ILM policy to what you want it to be  
Edit the template to what you want it to be but there are a few key differences see below...

```auto
{
  "index_templates": [
    {
      "name": "cis-metric-8.8.0",
      "index_template": {
        "index_patterns": [
          "cis-metric-8.8.0" <!-- NOTE IMPORTANT The name of the Data Stream
        ],
        "template": {
          "settings": {
            "index": {
              "lifecycle": {
                "name": "cis-metric"
              },
              "codec": "best_compression",
              "mapping": {
                "total_fields": {
                  "limit": "10000"
                }
              },
              "refresh_interval": "5s",
              "number_of_shards": "1",
              "max_docvalue_fields_search": "200",
              "query": {
                "default_field": [
                  "message",
                  "tags"
                ]
              }
            }
          },
          "mappings": {
            "_meta": {
              "beat": "metricbeat",
              "version": "8.8.0"
            },
            "dynamic_templates": [
              ......
              ],
            "date_detection": false,
            "properties": {
              ....... Mappings Here
            }
          }
        },
        "composed_of": [],
        "priority": 150,
        "data_stream": { <!--- NOTE IMPORTANT SUPER IMPORTANT I THINK YOU ARE MISSING THIS
          "hidden": false,
          "allow_custom_routing": false
        }
      }
    }
  ]
}

```

Then my metricbeat.yml looks like this...

```auto
setup.ilm.enabled: false
setup.template.enabled: false
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}"   
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

```

And now when I run metricbeat the data goes the correct places / data stream.

 ![Screenshot 2023-07-08 at 10.34.37 AM](https://us1.discourse-cdn.com/elastic/original/3X/3/a/3ac95695b4b1088a8772e61a6abc9375b72651a8.png)

YOU can do all this manually as well setup you your entire data stream by following [this](https://www.elastic.co/guide/en/elasticsearch/reference/current/set-up-a-data-stream.html)

I like the `setup` method because it creates everything for me then I just edit and change to what I want

**NOTE you are right** you can run the `setup` with just this and it set up the ILM, Data Stream and Template the other stuff not needed any more

setup config

```auto
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.policy_name: cis-metric

setup.template.enabled: true # <!--- You should explicitly set this 
setup.template.name: "cis-metric-%{[agent.version]}" # <!----This needs to match the index name because now it is a data stream
setup.template.pattern: "cis-metric-%{[agent.version]}" # <!-- Better matching Hygiene because it is a data stream 
setup.template.overwrite: false # <!--- Careful with this if set to true it will overwrite every time.

```

So run setup like that.

Then edit the ILM policy to what you want  
Edit the Template Mappings to what you want and you are good...

If you save all that stuff you can skip the setup... just create them and then run with your custom data stream name.

run config

```auto
setup.ilm.enabled: false
setup.template.enabled: false
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}"   
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

```

hope this helps

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 8, 2023, 6:41pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/14 "2023-07-08T18:41:50Z")

</div>

Hello @stephenb ,

I really appreciate your time and efforts to look into this and providing the needed settings to achieve my requirements. Many thanx for this! 😃

I won't be able to test this today, but I will follow what you have recommended.  
Just to calrify,If I'm getting you right.

Two methods:(Both methods assumes ILM is already defined)  
1\*\*)setup method\*\*(setup config):  
step1: commit the custom template  
step2: run setup config(provided above)  
**Note** in this method: `setup.ilm.policy_name: cis-metric` is provided in yml itself and in **method two** (run config) assumes ilm (index.lifecycle.name) to be part of template itself,from this it understands to pick ILM.

2) **run config method** (don't contain ilm settings in yml file and picks from template itself:index.lifecycle.name)  
step1: commit the custom template  
step 2:run setup config provided above

Will use the template you provided and edit just my mappings there.But i see this to be empty and do I need to fill something here, so that template works correct:

![image](https://us1.discourse-cdn.com/elastic/original/3X/5/a/5a5cae4abc02ef92b1e8a72ce9c79f477d6e7b09.png)  
?

If this works then I'm assuming heartbeat and filebeat also follows the same approach?

Thanks

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 8, 2023, 9:17pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/15 "2023-07-08T21:17:09Z")

</div>

> [@PRASHANT\_MEHTA](#):
>
> Two methods:(Both methods assumes ILM is already defined)  
> 1\*\*)setup method\*\*(setup config):

No ... the setup method I showed you will create A basic ILM policy for you... you can edit it from there. If you run the setup I showed you it will create the cis-metrics ILM policy

> [@PRASHANT\_MEHTA](#):
>
> Will use the template you provided and edit just my mappings there.But i see this to be empty and do I need to fill something here, so that template works correct:

Dynamic templates are up to you they are not required... you can read about them if you like, if you don't use them take them out...

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 10, 2023, 7:32am UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/16 "2023-07-10T07:32:17Z")

</div>

Hello @stephenb ,

Below is my custom index template and for this I tried two metricbeat.yml config and then started metricbeat`.Now data stream was not created`.

I hope the template you have shared was created custom and then tested?, bcz the syntax I see is of by deafult metricbeat in template and asked to add/edit additionaly1)my mappings 2)index patter anme,3)  
"data\_stream": {  
"hidden": false,  
"allow\_custom\_routing": false  
}  
Plz look my template and config metricbeat files.From what settings exaclty metricbeat will underastand to pick my own template,assuming below:  
1st case:  
setup.template.enabled: true  
setup.template.name: "cis-metric-%{[agent.version]}"  
setup.template.pattern: "cis-metric-%{[agent.version]}"

2nd case:(here ilm is not defined in what you have shared,then how it will understand which ILM)  
setup.ilm.enabled: false  
setup.template.enabled: false

I have changed in yml and in template the policy name to: cis-metric-policy as per my req.

Note: I'm building an ELK automation solution where in No user will ever come to Kibana page,  
admins just vist custom webui integrated dashbords.  
So what I do is,intially only create my cis-metric-policy with my settings in devtools/kibana policy page and then assumes when metricbeat will start with yml that also contains this policy name then it will automatically map to already created ILM policy.Intention to do so: No user will visit kibana page only webui.

```auto
PUT _index_template/cis-metric-8.7.1
{
        "index_patterns": [
          "cis-metric-8.7.1" 
        ],
        "template": {
          "settings": {
            "index": {
              "lifecycle": {
                "name": "cis-metric-policy"
              },
              "mapping": {
                "total_fields": {
                  "limit": "10000"
                }
              },
              "number_of_shards": "1"
            }
          },
          "mappings": {
            "properties": {
               "system.cpu.iowait.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.rss.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.write.bytes": {
          "type": "long"
        },
        "system.load.cores": {
          "type": "long"
        },
        "system.process.cpu.total.value": {
          "type": "long"
        },
        "service.type": {
          "type": "keyword"
        },
        "system.diskio.iostat.service_time": {
          "type": "float"
        },
        "system.memory.actual.free": {
          "type": "long"
        },
        "system.cpu.idle.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "agent.name": {
          "type": "keyword"
        },
        "system.memory.total": {
          "type": "long"
        },
        "system.diskio.write.time": {
          "type": "long"
        },
        "process.ppid": {
          "type": "long"
        },
        "system.diskio.iostat.write.await": {
          "type": "float"
        },
        "system.fsstat.total_size.free": {
          "type": "long"
        },
        "system.memory.free": {
          "type": "long"
        },
        "system.memory.swap.free": {
          "type": "long"
        },
        "system.memory.actual.used.pct": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.iostat.queue.avg_size": {
          "type": "float"
        },
        "agent.id": {
          "type": "keyword"
        },
        "system.memory.actual.used.bytes": {
          "type": "long"
        },
        "system.diskio.iostat.busy": {
          "type": "float"
        },
        "system.diskio.name": {
          "type": "keyword"
        },
        "system.cpu.user.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.memory.used.bytes": {
          "type": "long"
        },
        "system.network.name": {
          "type": "keyword"
        },
        "system.diskio.iostat.request.avg_size": {
          "type": "float"
        },
        "system.diskspace.usage": {
          "type": "long"
        },
        "system.cpu.system.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.request.merges_per_sec": {
          "type": "float"
        },
        "system.cpu.irq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "process.type": {
          "type": "keyword"
        },
        "process.details": {
          "type": "keyword"
        },
        "system.cpu.user.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "user.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.network.in.bytes": {
          "type": "long"
        },
        "system.network.in.dropped": {
          "type": "long"
        },
        "system.diskio.io.ops": {
          "type": "long"
        },
        "mountpoint.details": {
          "type": "keyword"
        },
        "system.diskio.iostat.write.per_sec.bytes": {
          "type": "float"
        },
        "system.fsstat.count": {
          "type": "long"
        },
        "system.load.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.process.cpu.total.ticks": {
          "type": "long"
        },
        "system.cpu.softirq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "metricset.period": {
          "type": "long"
        },
        "system.diskio.iostat.read.per_sec.bytes": {
          "type": "float"
        },
        "system.process.memory.share": {
          "type": "long"
        },
        "process.pgid": {
          "type": "long"
        },
        "system.process.memory.rss.bytes": {
          "type": "long"
        },
        "@timestamp": {
          "type": "date"
        },
        "system.network.in.errors": {
          "type": "long"
        },
        "system.process.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.memory.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.await": {
          "type": "float"
        },
        "system.cpu.irq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "process.pid": {
          "type": "long"
        },
        "system.load.norm.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.read.count": {
          "type": "long"
        },
        "system.filesystem.used.pct": {
          "type": "float"
        },
        "system.cpu.iowait.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.size": {
          "type": "long"
        },
        "system.network.out.dropped": {
          "type": "long"
        },
        "cpu.status": {
          "type": "keyword"
        },
        "host.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.diskio.iostat.await": {
          "type": "float"
        },
        "system.network.out.packets": {
          "type": "long"
        },
        "system.cpu.steal.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.steal.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.write.count": {
          "type": "long"
        },
        "process.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.diskio.read.time": {
          "type": "long"
        },
        "system.diskio.serial_number": {
          "type": "keyword"
        },
        "system.fsstat.total_files": {
          "type": "long"
        },
        "system.network.in.packets": {
          "type": "long"
        },
        "system.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.network.out.errors": {
          "type": "long"
        },
        "system.diskio.iostat.write.request.merges_per_sec": {
          "type": "float"
        },
        "system.memory.swap.total": {
          "type": "long"
        },
        "system.diskio.io.time": {
          "type": "long"
        },
        "system.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.cpu.cores": {
          "type": "long"
        },
        "system.fsstat.status": {
          "type": "keyword"
        },
        "system.cpu.softirq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.norm.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.iostat.write.request.per_sec": {
          "type": "float"
        },
        "system.diskio.read.bytes": {
          "type": "long"
        },
        "system.fsstat.total_size.used": {
          "type": "long"
        },
        "system.load.norm.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.process.cpu.start_time": {
          "type": "date"
        },
        "system.memory.swap.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.idle.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.request.per_sec": {
          "type": "float"
        },
        "system.network.out.bytes": {
          "type": "long"
        },
        "system.memory.swap.used.bytes": {
          "type": "long"
        },
        "process.args": {
          "type": "keyword"
        },
        "system.cpu.system.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "metricset.name": {
          "type": "keyword"
        },
        "system.fsstat.total_size.total": {
          "type": "long"
        },
        "system.process.state": {
          "type": "keyword"
        }
            }
          }
        },
        "composed_of": [],
        "data_stream": {  
          "hidden": false,
          "allow_custom_routing": false
        }
}

```

metricbeat.yml config 1:

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.policy_name: cis-metric-policy
setup.template.enabled: true 
setup.template.name: "cis-metric-%{[agent.version]}" 
setup.template.pattern: "cis-metric-%{[agent.version]}"  
setup.template.overwrite: false 
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["https://abc:443"]
  index: "cis-metric-%{[agent.version]}"
  ssl.certificate_authorities: ["/l/ppp/config/ece_proxy_root_ca.pem"]
  protocol: "https"
  username: ""
  password: ""
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event

```

Above congig didn't work then tried this:

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: false
setup.template.enabled: false 
setup.kibana:
  host: https://abc:5601
output.elasticsearch:
  hosts: ["https://abc:443"]
  index: "cis-metric-%{[agent.version]}"
  ssl.certificate_authorities: ["/l/ppp/config/ece_proxy_root_ca.pem"]
  protocol: "https"
  username: ""
  password: ""
processors:
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event

```

Both ways data stream was not created.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 10, 2023, 2:33pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/17 "2023-07-10T14:33:29Z")

</div>

Hi @PRASHANT_MEHTA

I get your requirement....I think you're missing _my_ point. 🙂  
If you run `setup` the way I showed you, it gives you all the correct assets... Best Practice assets (ILM, policy, template, data stream etc) it was just a way of getting a set of best practice assets.

Afterward, you just edit them to meet your requirements.  
Then can you just capture those with a GET command (fix the opening and closing {}) fix mappings to what you want then POST and create the assets as part of your automation before you run metricbeat.

**I think the confusion is that since you are creating all the assets MANUALLY you do not need to run `setup` and the datastream is created when you run metricbeat at runtime.** not during setup ... which does not need to be run

Here is my complete code process using **YOUR** template (I changed the version number only)

First Clean Up and Post all the Assets ILM Policy and template

```auto
DELETE _data_stream/cis-metric-8.8.0

GET _ilm/policy/cis-metric-policy

DELETE _ilm/policy/cis-metric-policy

PUT _ilm/policy/cis-metric-policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "30d",
            "max_primary_shard_size": "50gb"
          }
        }
      }
    }
  }
}

DELETE _index_template/cis-metric-8.8.0

# NOTE THIS IS YOUR TEMPLATE WITH JUST THE VERSION CHANGED

PUT _index_template/cis-metric-8.8.0
{
  "index_patterns": [
    "cis-metric-8.8.0"
  ],
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "cis-metric-policy"
        },
        "mapping": {
          "total_fields": {
            "limit": "10000"
          }
        },
        "number_of_shards": "1"
      }
    },
    "mappings": {
      "properties": {
        "system.cpu.iowait.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.rss.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.write.bytes": {
          "type": "long"
        },
        "system.load.cores": {
          "type": "long"
        },
        "system.process.cpu.total.value": {
          "type": "long"
        },
        "service.type": {
          "type": "keyword"
        },
        "system.diskio.iostat.service_time": {
          "type": "float"
        },
        "system.memory.actual.free": {
          "type": "long"
        },
        "system.cpu.idle.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "agent.name": {
          "type": "keyword"
        },
        "system.memory.total": {
          "type": "long"
        },
        "system.diskio.write.time": {
          "type": "long"
        },
        "process.ppid": {
          "type": "long"
        },
        "system.diskio.iostat.write.await": {
          "type": "float"
        },
        "system.fsstat.total_size.free": {
          "type": "long"
        },
        "system.memory.free": {
          "type": "long"
        },
        "system.memory.swap.free": {
          "type": "long"
        },
        "system.memory.actual.used.pct": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.iostat.queue.avg_size": {
          "type": "float"
        },
        "agent.id": {
          "type": "keyword"
        },
        "system.memory.actual.used.bytes": {
          "type": "long"
        },
        "system.diskio.iostat.busy": {
          "type": "float"
        },
        "system.diskio.name": {
          "type": "keyword"
        },
        "system.cpu.user.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.memory.used.bytes": {
          "type": "long"
        },
        "system.network.name": {
          "type": "keyword"
        },
        "system.diskio.iostat.request.avg_size": {
          "type": "float"
        },
        "system.diskspace.usage": {
          "type": "long"
        },
        "system.cpu.system.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.request.merges_per_sec": {
          "type": "float"
        },
        "system.cpu.irq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "process.type": {
          "type": "keyword"
        },
        "process.details": {
          "type": "keyword"
        },
        "system.cpu.user.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "user.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.network.in.bytes": {
          "type": "long"
        },
        "system.network.in.dropped": {
          "type": "long"
        },
        "system.diskio.io.ops": {
          "type": "long"
        },
        "mountpoint.details": {
          "type": "keyword"
        },
        "system.diskio.iostat.write.per_sec.bytes": {
          "type": "float"
        },
        "system.fsstat.count": {
          "type": "long"
        },
        "system.load.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.process.cpu.total.ticks": {
          "type": "long"
        },
        "system.cpu.softirq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "metricset.period": {
          "type": "long"
        },
        "system.diskio.iostat.read.per_sec.bytes": {
          "type": "float"
        },
        "system.process.memory.share": {
          "type": "long"
        },
        "process.pgid": {
          "type": "long"
        },
        "system.process.memory.rss.bytes": {
          "type": "long"
        },
        "@timestamp": {
          "type": "date"
        },
        "system.network.in.errors": {
          "type": "long"
        },
        "system.process.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.nice.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.memory.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.await": {
          "type": "float"
        },
        "system.cpu.irq.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "process.pid": {
          "type": "long"
        },
        "system.load.norm.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.read.count": {
          "type": "long"
        },
        "system.filesystem.used.pct": {
          "type": "float"
        },
        "system.cpu.iowait.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.memory.size": {
          "type": "long"
        },
        "system.network.out.dropped": {
          "type": "long"
        },
        "cpu.status": {
          "type": "keyword"
        },
        "host.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.diskio.iostat.await": {
          "type": "float"
        },
        "system.network.out.packets": {
          "type": "long"
        },
        "system.cpu.steal.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.steal.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.write.count": {
          "type": "long"
        },
        "process.name": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "system.diskio.read.time": {
          "type": "long"
        },
        "system.diskio.serial_number": {
          "type": "keyword"
        },
        "system.fsstat.total_files": {
          "type": "long"
        },
        "system.network.in.packets": {
          "type": "long"
        },
        "system.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.network.out.errors": {
          "type": "long"
        },
        "system.diskio.iostat.write.request.merges_per_sec": {
          "type": "float"
        },
        "system.memory.swap.total": {
          "type": "long"
        },
        "system.diskio.io.time": {
          "type": "long"
        },
        "system.cpu.total.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.15": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.cpu.cores": {
          "type": "long"
        },
        "system.fsstat.status": {
          "type": "keyword"
        },
        "system.cpu.softirq.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.load.norm.5": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.diskio.iostat.write.request.per_sec": {
          "type": "float"
        },
        "system.diskio.read.bytes": {
          "type": "long"
        },
        "system.fsstat.total_size.used": {
          "type": "long"
        },
        "system.load.norm.1": {
          "scaling_factor": 100,
          "type": "scaled_float"
        },
        "system.process.cpu.start_time": {
          "type": "date"
        },
        "system.memory.swap.used.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.cpu.idle.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.diskio.iostat.read.request.per_sec": {
          "type": "float"
        },
        "system.network.out.bytes": {
          "type": "long"
        },
        "system.memory.swap.used.bytes": {
          "type": "long"
        },
        "process.args": {
          "type": "keyword"
        },
        "system.cpu.system.norm.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "system.process.cpu.total.pct": {
          "scaling_factor": 1000,
          "type": "scaled_float"
        },
        "metricset.name": {
          "type": "keyword"
        },
        "system.fsstat.total_size.total": {
          "type": "long"
        },
        "system.process.state": {
          "type": "keyword"
        }
      }
    }
  },
  "composed_of": [],
  "data_stream": {
    "hidden": false,
    "allow_custom_routing": false
  }
}

```

Then this is my metricbeat config... all that is needed for the template, IILM and output section (I am not looking at all your other config.

```auto
setup.ilm.enabled: false
setup.template.enabled: false
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}"   
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

```

**AND I think this is your confusion since you set everything up Manually you do NOT need to run `setup` command** the datastream is created at first run / run time

Then simply run  
`metricbeat -e`  
Or however, you want to run and the Data Stream is created at run time using the assets you previously installed.

That is all I did and I used **your** template

GET \_data\_stream/cis-metric-8.8.0

```auto
{
  "data_streams": [
    {
      "name": "cis-metric-8.8.0",
      "timestamp_field": {
        "name": "@timestamp"
      },
      "indices": [
        {
          "index_name": ".ds-cis-metric-8.8.0-2023.07.10-000001",
          "index_uuid": "dUKP92isQX2DUHbM4CaX7A"
        }
      ],
      "generation": 1,
      "status": "YELLOW",
      "template": "cis-metric-8.8.0",
      "ilm_policy": "cis-metric-policy",
      "hidden": false,
      "system": false,
      "allow_custom_routing": false,
      "replicated": false
    }
  ]
}

```

 ![Screenshot 2023-07-10 at 7.28.25 AM](https://us1.discourse-cdn.com/elastic/original/3X/5/f/5ffb8f900b7a7bdc391618f25e8b62182c91c4be.jpeg)  
 ![Screenshot 2023-07-10 at 7.28.34 AM](https://us1.discourse-cdn.com/elastic/original/3X/a/b/aba635a59f7c2a1f0daf1fc336e543942b196353.png)

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 10, 2023, 3:32pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/18 "2023-07-10T15:32:55Z")

</div>

@stephenb ,

Thanx again for your time to look into this. I will do whatever you recommended above and may test in few hours.Thanx for your patience 😅,Migration is hectic.  
Only confusion: Where the datastream will understand which policy to follow for cis-metric-8.7.1,as in below config ilm policy info is not there,even what I do PUT ILM policy and template itself first in devtools then run metricbeat.I'm thinking how the data stream will get to know which policy to follow with below:

```auto
setup.ilm.enabled: false
setup.template.enabled: false
output.elasticsearch:
  hosts: ["https://localhost:9200"]
  index: "cis-metric-%{[agent.version]}"   
  username: "elastic"
  password: "password"
  ssl.verification_mode: "none"

```

If you understood me right,what I do:  
1)First commit template and ILM in devtools  
2)run metricbrat.yml  
3)Expect that data stream will now map with my template only and follow my ILM only(commited earlier in dev tools)

How metric beat is run by me:

start.sh

```auto
#!/bin/ksh
echo "Starting metricbeat..."
./metricbeat & 
_pid=$! 
echo "$_pid" > metricbeat.pid
echo "Pid $_pid stored in metricbeat.pid"

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b7d1702337d41769d8a3d807d839efa15bd48567.png)

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 10, 2023, 3:38pm UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/19 "2023-07-10T15:38:30Z")

</div>

> [@PRASHANT\_MEHTA](#):
>
> Only confusion: Where the datastream will understand which policy to follow for cis-metric-8.7.1,as in below config ilm policy info is not there,even what I do PUT ILM policy and template itself first in devtools then run metricbeat.

It is defined in the template that is all that is needed...  
Yes if you put the ILM policy and the template in FIRST before running metricbeat then it should work.

```auto
PUT _index_template/cis-metric-8.8.0
{
  "index_patterns": [
    "cis-metric-8.8.0"
  ],
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "cis-metric-policy" <!---- Right Here
        },

```

BTW all the manual setup (i.e. no running `setup` ) is actually a very common approach for customized deployments.

---

<div class="post-metadata">

### Author: ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)
#### Post date: [July 11, 2023, 11:10am UTC](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557/20 "2023-07-11T11:10:30Z")

</div>

Hello @stephenb ,

Many thanx for your time on this.Everytime I wondered same index template and ILM I provided you and things work fine with you and not my end.  
Now issue is resolved but please be informed how its working now and not previously.

How issue got solved:

**As you mentioned you are using 8.8.0** ,here this is valid(cis-metric-%{[agent.version]}),same is not valid in 8.7.1 and I need to manually put index name only and now it works,weird:

**8.8.0:**

```auto
index: "cis-metric-%{[agent.version]}"(yml)

```

I'm using 8.7.1 version and I need to do below,this is not good practice,any alterantive or what might be the reason in 8.7.1 this cis-metric-**%{[agent.version]}** dont work:  
**8.7.1** using below then only data stream created.  
`index: "cis-metric-8.7.1"`(yml)

Alternatively do u think it would be fine if i remove 8.7.1 from-index pattern,template and from yml and instead only use cis-metric only.

I hope similar is the approach for all beats i.e heartbeat and filebeat(custom template and ilm),like how did for metricbeat for data streams?

[Next page](https://discuss.elastic.co/t/metricbeat-and-heartbeat-8-x-custom-index-name-should-pickup-from-template-but-creates-always-bedefault-index-name/337557.md?page=2)
