2016-06-07 2 views
1

Filebeat, Logstash, ElasticSearch 및 Kibana가 있습니다. Filebeat는 별도의 서버에 있으며 syslog, json, 데이터베이스 등 다른 형식으로 데이터를 수신하여 Logstash로 보냅니다.Filebeat 및 LogStash - 여러 형식의 데이터

Logstash가 단일 형식을 처리하도록 설정하는 방법을 알고 있지만 여러 데이터 형식이 있으므로 각 데이터 형식을 올바르게 처리하도록 Logstash를 구성하는 방법은 무엇입니까?

실제로 Logstash와 Filebeat를 모두 설정하여 다른 형식의 모든 데이터를 Filebeat에서 보내고 Logstash에 제대로 제출할 수 있습니까? 내 말은, 데이터를 송수신하는 설정을 의미합니다.

답변

5

Logstash 파이프 라인에서 다른 유형의 입력을 분리하려면 식별을 위해 type 필드와 tags 필드를 사용하십시오.

Filebeat 구성에서 각기 다른 데이터 형식에 대해 다른 광도계를 사용해야하며 각 광도계에 다른 document_type: 필드가 설정 될 수 있습니다. 예를 들어

Reference

: 다른 광부가 document_type: log_message있는 동안 상기 예에서

filebeat: 
    # List of prospectors to fetch data. 
    prospectors: 
    # Each - is a prospector. Below are the prospector specific configurations 
    - 
     # Paths that should be crawled and fetched. Glob based paths. 
     # For each file found under this path, a harvester is started. 
     paths: 
     - "/var/log/apache/httpd-*.log" 
     # Type to be published in the 'type' field. For Elasticsearch output, 
     # the type defines the document type these entries should be stored 
     # in. Default: log 
     document_type: apache 
    - 
     paths: 
     - /var/log/messages 
     - "/var/log/*.log" 
     document_type: log_message 

/var/log/apache/httpd-*.log의 로그는 document_type: apache있을 것이다.

document-type 필드는 Logstash가 이벤트를 처리 할 때 type 필드가됩니다. 그런 다음 Logstash에서 if 문을 사용하여 다른 유형에 대해 다른 처리를 수행 할 수 있습니다. 예를 들어

Reference

: 귀하의 질문에 "데이터 형식"코덱 인 경우

filter { 
    if [type] == "apache" { 
    # apache specific processing 
    } 
    else if [type] == "log_message" { 
    # log_message processing 
    } 
} 
+0

하지만 syslog 형식의 일부 메시지와 json의 다른 메시지는 어떻게됩니까? "코덱"을 logstash의 "output"에 지정해야합니까? –

+0

나는 filebeat에서 오는 것들을 logstash로 가져옵니다. –

+0

코덱은 logstash elasticsearch 출력 –

1

,이 logstash의 입력으로 구성되어야한다. 다음은 탄성 5 스택이 아닌 filebeat 1.x 및 logstash 2.x에 관한 것입니다. 우리의 설정에서 , 우리는 두 개의 비트 입력이 - 첫 번째 기본 = "일반"입니다 다음 filebeat 측면에서

beats { 
    port    => 5043 
} 
beats { 
    port    => 5044 
    codec    => "json" 
} 

, 우리는 각각의 포트에 자신의 출력을 보내는 두 filebeat 인스턴스가 필요합니다. filebeat에게 "이 잠재 고객을 출력으로 라우팅"하는 것은 불가능합니다.

문서 logstash : https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-beats.html

비고 : 서로 다른 프로토콜을 제공하는 경우, 예를 들어, 기존 logstash-forwarder/lumberjack을 사용하려면 더 많은 포트가 필요합니다.