# Filebeatでインデックス名を任意に作成する方法

**URL:** https://discuss.elastic.co/t/filebeat/193921
**Category:** 日本語による質問・議論はこちら
**Created:** [August 6, 2019, 5:17am UTC](https://discuss.elastic.co/t/filebeat/193921 "2019-08-06T05:17:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![t-nakata](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@t-nakata](https://discuss.elastic.co/u/t-nakata)
#### Post date: [August 6, 2019, 5:17am UTC](https://discuss.elastic.co/t/filebeat/193921/1 "2019-08-06T05:17:47Z")

</div>

filebeat.ymlにインデックス名の設定をしてElasticSearchからファイルを転送したのですが、デフォルトのインデックス名(filebeat-%{[agent.version]}-%{+yyyy.MM.dd})で作成されてしまいます。インデックスを任意に指定する方法を教えて下さい

■filebeat.yml設定内容(抜粋)  
#==================== Elasticsearch template setting ==========================

setup.template.name: "filebeat-test"  
setup.template.pattern: "filebeat-test\*"  
setup.template.settings:  
index.number\_of\_shards: 5  
#index.codec: best\_compression  
#\_source.enabled: false

#================================ General =====================================

-------------------------- Elasticsearch output ------------------------------  
output.elasticsearch: # Array of hosts to connect to.  
hosts: ["localhost:9200"]  
index: "filebeat-test-%{[agent.version]}-%{+yyyy.MM.dd}"

---

<div class="post-metadata">

### Author: ![tsgkdt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsgkdt/32/39151_2.png) [@tsgkdt](https://discuss.elastic.co/u/tsgkdt)
#### Post date: [August 6, 2019, 5:48am UTC](https://discuss.elastic.co/t/filebeat/193921/2 "2019-08-06T05:48:05Z")

</div>

こんにちわ。

お使いのバージョンが書かれていないので、7.3.0だと仮定して書きます。

設定箇所としては、outputところでのindexと、templateの設定でindex名は指定できますが、  
ILMの部分の設定はどのようにされてますでしょうか？

```yaml
#============================== Setup ILM =====================================

# Configure index lifecycle management (ILM). These settings create a write
# alias and add additional settings to the index template. When ILM is enabled,
# output.elasticsearch.index is ignored, and the write alias is used to set the
# index name.

# Enable ILM support. Valid values are true, false, and auto. When set to auto
# (the default), the Beat uses index lifecycle management when it connects to a
# cluster that supports ILM; otherwise, it creates daily indices.
#setup.ilm.enabled: auto

```

ここによりますと、ILMが有効だと output.elasticsearch.indexの設定値は無視されるとあります。

> When ILM is enabled, output.elasticsearch.index is ignored,

デフォルトはauto(true)なので、この設定のためにインデックス名を指定できていないのではないでしょうか？

ILMが有効だと、setup.ilm.rollover\_aliasの値も設定する必要があるかと思います。

> setup.ilm.rollover\_alias: "forumtest"

---

<div class="post-metadata">

### Author: ![t-nakata](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@t-nakata](https://discuss.elastic.co/u/t-nakata)
#### Post date: [August 6, 2019, 7:00am UTC](https://discuss.elastic.co/t/filebeat/193921/3 "2019-08-06T07:00:50Z")

</div>

setup.ilm.rollover\_aliasの設定で解決できました。  
以前これも試していたのですが、設定方法が誤っていたようです。  
ご回答ありがとうございました。

---

<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: [September 3, 2019, 7:01am UTC](https://discuss.elastic.co/t/filebeat/193921/4 "2019-09-03T07:01:00Z")

</div>

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