2016-06-07 2 views
2

이렇게 탄성 적층을 설정했습니다. 필자는 사용자 정의 인덱스 이름을 사용하여 Filebeat 및 Topbeat를 통해 로그 및 최상위 데이터를 전달하려고합니다.Logstash가 Filebeat 및 Packetbeat에 대한 올바른 색인을 작성하지 않음

비록 Logstash가 사용자 지정 인덱스 이름과 함께 전달하는 데이터에 대한 인덱스를 만들지는 않지만.

Logstash의 설정 :

input{ 
    beats{ 
     port => 27080 
     congestion_threshold => 1500 
    } 
    jmx { 
     path => "file://Machine01/Users/username/projects/Logstash/logstash/bin/jmx" 
     polling_frequency => 15 
     type => "jmx" 
     nb_thread => 4 
} 
} 
filter { 
    if [type] == "Type1"{ 
     grok{ 
      break_on_match => false 
      patterns_dir => ["C:\Users\users\projects\Logstash\logstash\bin\patterns"] 
      match => { "message" => "%{YEAR:Year}%{MONTHNUM:Month}%{MONTHDAY:Day} %{HOUR:Hour}%{MINUTE:Minute}%{SECOND:Second} %{LogLevel:LogVerbosity} %{MODULE:MODULENAME}%{SPACE}%{MESSAGEID:MESSAGEID} %{SUBMODULE:SUBMODULE} %{MESSAGE:MESSAGE}"} 
      add_field => [ "received_at", "%{@timestamp}" ] 
      add_field => [ "received_from", "%{host}" ] 
      add_tag => ["Groked"] 
     } 



if "_grokparsefailure" in [tags] { 
       drop { } 
    } 

    if [type] == "jmx" { 
    if ("OperatingSystem.ProcessCpuLoad" in [metric_path] or "OperatingSystem.SystemCpuLoad" in [metric_path]) { 
    ruby { 
    code => "event['cpuLoad'] = event['metric_value_number'] * 100" 
    add_tag => [ "cpuLoad" ] 
    } 
    } 
} 
    } 
} 

output { 
    if [type] == "jmx" { 
     elasticsearch { 
      hosts => ["http://localhost:9200"] 
      index => "jmx-%{+YYYY.MM.dd}" 
     } 
    } else { 
     elasticsearch { 
      hosts => ["http://localhost:9200"] 
      manage_template => true 
      index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" 
      document_type => "%{[@metadata][type]}" 
     } 

     if [type] == "dbtable" { 
     elasticsearch { 
      hosts => ["http://localhost:9200"] 
      index => "dbtable-%{+YYYY.MM.dd}" 

     } 
    } 
    } 
} 

Filebeat의 설정 : 내가 index: custom를 설정할 때, 그것은 "사용자 정의-YYYY.MM.DD"로 Elasticsearch에 인덱스를 생성해야합니다 기대하고

filebeat: 
    prospectors: 
    - paths: 
     - test.log 
     input_type: log 
     tail_files: false 
     scan_frequency: 3s 
     backoff: 20s 
     backoff_factor: 1 
     document_type: custom 
     registry: 
     fields: 
     type: custom 
    spool_size: 10000 
    idle_timeout: 2s 
output: 
    logstash: 
    index: custom 
    hosts: ["valid hostname"] 
logging: 
    to_files: true 
    files: 
    path: ./ 
    name: filebeat.log 
    rotateeverybytes: 10485760 
    level: debug 

. 그러나 Elasticsearch에서 "%{[@metadata][beat]}-%{+YYYY.MM.dd}"으로 색인을 생성하는 것입니다.

내가 #index: custom이라고 대답하면 Elasticsearch에 색인이 filebeat-YYYY.MM.dd으로 생성됩니다.

내가 잘못 가고 있는데 왜 사용자 정의 색인 패턴에서 작동하지 않습니까?

답변

2

Filebeat output.logstash.index 구성 매개 변수를 설정하면 사용자 지정 인덱스 이름이 [@metadata][beat] 값보다 우선합니다. 일반적으로 [@metadata][beat] 값은 비트 (예 : 파일 비트 또는 패킷 비트)의 이름입니다.

Logstash에 대해 Filebeat 구성을 테스트하면 [@metadata][beat] 값이 custom으로 설정되어 Filebeat 구성이 정상적으로 작동 함을 알 수 있습니다.

출력 구성에 사용 된 조건부 논리에 문제가있을 수 있습니다. 좀 더 간결하게 출력 설정을 단순화했습니다. 당신이 비츠의와 정의 인덱스를 사용하는 경우

output { 
    # Remove this after you finish debugging. 
    stdout { codec => rubydebug { metadata => true } } 

    if [@metadata][beat] { 
    # Use this output only for Beats. 
    elasticsearch { 
     hosts => ["http://localhost:9200"] 
     manage_template => false 
     index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" 
     document_type => "%{[@metadata][type]}" 
    } 
    } else if [type] == "jmx" or [type] == "dbtable" { 
    elasticsearch { 
     hosts => ["http://localhost:9200"] 
     index => "%{[type]}-%{+YYYY.MM.dd}" 
    } 
    } 
} 

설치하고 (Logstash의 manage_template => true 구타와를 사용하지 않음) 인덱스 템플릿을 정의해야한다. Filebeat는 다운로드시 배포되는 filebeat.template.json file에 색인 템플릿을 제공합니다. template 행을 "filebeat- *"대신 "custom- *"색인에 적용되도록 변경해야합니다. 그런 다음 curl -XPUT http://localhost:9200/_template/custom [email protected]을 사용하여 Elasticsearch에 템플릿을 설치하십시오.

관련 문제