2016-10-20 8 views
1

logstash가 읽는 파일의 이름을 ElasticSearch의 출력 색인 이름으로 사용하는 방법이 있습니까?Logstash 입력 파일 이름을 출력 elasticsearch index

logstash에 다음 구성을 사용하고 있습니다.

input{ 
    file{ 
     path => "/logstashInput/*" 
    } 
} 
output{ 
    elasticsearch{ 
     index => "FromfileX" 
    } 
} 

나는 파일 e.g. log-from-20.10.2016.log을 넣을 수 있기를 좋아하고 인덱스 log-from-20.10.2016로 색인 할 것이다. Logstash 입력 플러그인 "file"이 필터 또는 출력에 사용할 변수를 생성합니까?

답변

1

예, 당신은에 대한 path 필드를 사용할 수 있으며 grok 그것은 index 필드

input { 
    file { 
     path => "/logstashInput/*" 
    } 
    } 
    filter { 
    grok { 
     match => ["path", "(?<index>log-from-\d{2}\.\d{2}\.\d{4})\.log$" ] 
    } 
    } 
    output{ 
    elasticsearch { 
     index => "%{index}" 
    } 
    } 
+0

이 어떤 행운에 파일 이름을 추출하기 위해? – Val