# Filebeat 指定したindex名で登録されない

**URL:** <https://discuss.elastic.co/t/filebeat-index/202289>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [October 4, 2019, 6:45am UTC](https://discuss.elastic.co/t/filebeat-index/202289 "2019-10-04T06:45:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harue](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@harue](https://discuss.elastic.co/u/harue)\
**Post date:** [October 4, 2019, 6:45am UTC](https://discuss.elastic.co/t/filebeat-index/202289/1 "2019-10-04T06:45:35Z")

</div>

お世話になります。

現在、Filebeat→Elasticsearch(Ingest node)の疎通を試しています。

バージョン…各7.3

◆実現したいこと  
・Filebeat.ymlに定義したindex名で登録  
・Filebeat.ymlに定義したingest nodeの処理を実施

◆設定値

filebeat.yml

```
#=========================== Filebeat inputs =============================

filebeat.inputs:

- type: log
 tags: ["access"]
 enabled: true
 paths:
   - /var/log/squid/access*.log

- type: log
 tags: ["cache"]
 enabled: true
 paths:
  - /var/log/*.log
  
#==================== Elasticsearch template setting ==========================

setup.template.name: "squid"
setup.template.pattern: "squid*"
setup.template.settings:
  index.number_of_shards: 5

#-------------------------- Elasticsearch output ------------------------------

output.elasticsearch:
   hosts: ["XX.XXX.XXX.XXX:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
   username: "elastic"
   password: "XXX"

   pipelines:
     - pipeline: "squid_access"
       when.equals:
         tags[0]: "access"
     - pipeline: "squid_cache"
       when.equals:
         tags[0]: "cache"

   indices:
     - index: "squid_access"
        when.equals:
          tags[0]: "access"
     - index: "squid_cache"
        when.equals:
          tags[0]: "cache"

   setup.ilm.rollover_alias: "squid"

```

◆ご質問

上記設定値にてFilebeatのinput path「/var/log/\*.log」にログを格納したところ、  
indexは登録されましたが以下の結果となりました。

・index名が「filebeat-7.4.0-2019.10.03-000001」とならない  
→tags「cache」のデータのため、index名は「squid\_cache」になる想定でした

・登録されたデータがingest nodeの処理を通っていない  
→pipeline: "squid\_cache"にてKV Proccesorを定義しているのですが処理結果が設定されていない

[https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html](https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html)  
上記のindexを参照し以下の項目を設定する必要があると認識しています。

setup.template.name  
setup.template.pattern  
setup.ilm.rollover\_alias(ILMが有効になっているため)

設定値に誤り・不足はありますでしょうか。  
指定したindex名とならない原因が分かりましたら教えてください。

---

<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:** [October 4, 2019, 7:41am UTC](https://discuss.elastic.co/t/filebeat-index/202289/2 "2019-10-04T07:41:05Z")

</div>

tags[0]のequalsではなくcontainsで書いた場合ですと、動かしてみたところ問題なさそうに見えます。

when.equalsのところをcontainsにし、tags[0]をtagsに変更しただけです。

```auto
output.elasticsearch:
  hosts: ["localhost:9200"]

 # (中略）

  pipelines:
    - pipeline: "squid_access"
      when.contains:
        tags: "access"
    - pipeline: "squid_cache"
      when.contains:
        tags: "cache"

  indices:
    - index: "squid_access"
      when.contains:
        tags: "access"
    - index: "squid_cache"
      when.contains:
        tags: "cache"

  setup.ilm.rollover_alias: "squid"

```

Index名やPipelineの実行が期待通りとならない件については、これで確認いただけるのではないかと思います。  
お試しください。

---

<div class="post-metadata">

**Author:** ![harue](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@harue](https://discuss.elastic.co/u/harue)\
**Post date:** [October 6, 2019, 11:47pm UTC](https://discuss.elastic.co/t/filebeat-index/202289/3 "2019-10-06T23:47:54Z")

</div>

返信が遅れ失礼しました。

回答頂きありがとうございます。

> when.equalsのところをcontainsにし、tags[0]をtagsに変更しただけです。  
> →上記にて試したところうまくいきました。

大変助かりました。ありがとうございました。

---

<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:** [November 3, 2019, 11:48pm UTC](https://discuss.elastic.co/t/filebeat-index/202289/4 "2019-11-03T23:48:02Z")

</div>

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