# 동일 로그에 대한 다중 인덱스 생성 방법

**URL:** <https://discuss.elastic.co/t/topic/250610>\
**Category:** Logstash\
**Tags:** elastic-stack-monitoring\
**Created:** [October 1, 2020, 7:08am UTC](https://discuss.elastic.co/t/topic/250610 "2020-10-01T07:08:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwwryuwww](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wwwryuwww/32/74674_2.png) [@wwwryuwww](https://discuss.elastic.co/u/wwwryuwww)\
**Post date:** [October 1, 2020, 7:08am UTC](https://discuss.elastic.co/t/topic/250610/1 "2020-10-01T07:08:10Z")

</div>

현재 filebeat -\> logstash -\> elasticsearch 구조로 모두 6.6.2 버전을 사용하고 있는데  
동일 서버 내 한 개의 서비스 로그를 내용 패턴과 생성 목적에 따라서  
별도의 인덱스로 elasticsearch에 저장하고자 합니다.

"customs.log" -\> 1. index "case1"  
-\> 2. index "case2"

현재는 서버의 filebeat에서 동일한 파일에 대하여 각각 input 설정을 하였고  
원하는대로 인덱스 내 데이터들은 구성이 되고 있기는 하지만 필요없이 동일 로그를 두 번씩 logstash로 보내는 상황 입니다.

아래의 현재 filebeat 설정에서 각각을 별도 input으로 하지 않고  
tags: ["case1", "case2"] 로 설정해 보았는데  
filebeat의 output을 파일로 떨어뜨려서 확인해 보면 각각의 데이터마다 위 두개의 태그가 함께 설정된 것이 확인 되는데  
filebeat나 logstash에서의 별다른 에러로그는 없어도 "case1" 인덱스나 "case2" 인덱스로 데이터가 들어오지 않았습니다.

방법 아시는 분 도움 좀 요청 드립니다.

[현재 filebeat 설정(filebeat의 중복 데이터 송신)]

```
filebeat.inputs:
- type: log
  tags: ["case1"]
  enabled: true
  paths: 
      - /jb_log/custom.log

- type: log
  tags: ["case2"]
  enabled: true
  paths:
      - /jb_log/custom.log

filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false

output.logstash
  hosts: ["172.16.1.10:5044"]

```

[현재 logstash 설정]

```
input {
  beats {
    port => 5044
  }
}

filter {
  if "case1" in [tags] {
     `...`
    }
  else if "case2" in [tags] {
      `...`
    }
}

output {
  if "case1" in [tags] {
    elasticsearch {
      action => "create"
      hosts => ["localhost:9200"]
      index => "case1"
      document_id => "%{@timestamp}"
    }
  }
  
  else if "case2" in [tags] {
    elasticsearch {
      action => "create"
      hosts => ["localhost:9200"]
      index => "case2"
      document_id => "%{[computed_id]}"
      }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 1, 2020, 2:38pm UTC](https://discuss.elastic.co/t/topic/250610/2 "2020-10-01T14:38:09Z")

</div>

If you want one log file processed in two different ways you can use pipeline to pipeline communications with a [forked path pattern](https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html#forked-path-pattern).

---

<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:** [October 29, 2020, 2:38pm UTC](https://discuss.elastic.co/t/topic/250610/3 "2020-10-29T14:38:10Z")

</div>

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