2017-10-11 47 views
0

我可以使用logstash.conf創建索引。我的輸入類型是gelf。 我正在將logstash日誌發送給kibana。 這裏是我的logstash.conf無法在kibana中獲取索引相關數據

input 
{ gelf { } 
} 
output 

{ 
stdout { codec => rubydebug } 
elasticsearch { 
    hosts => ["elk.lera.com:80"] 
    index => "templeton-math-%{+YYYY.MM.dd}" 
} 

elasticsearch { 
    hosts => ["elk.lera.com:80"] 
    index => "templeton-science-%{+YYYY.MM.dd}" 
} 
elasticsearch { 
    hosts => ["elk.lera.com:80"] 
    index => "templeton-bio-%{+YYYY.MM.dd}" 
} 
elasticsearch { 
    hosts => ["elk.lera.com:80"] 
    index => "templeton-lang-%{+YYYY.MM.dd}" 
} 
} 

問題:現在的日誌發送到所有的指標。我想將日誌發送到相應的索引。

我已經加入像

if[tag] == "templeton-math"{ 
elasticsearch { 
    hosts => ["elk.lera.com:80"] 
    index => "templeton-math-%{+YYYY.MM.dd}" 
} 
} 

它給了一個錯誤 INFO logstash.agent - 沒有找到持久的UUID文件。生成新的UUID {:uuid =>「67f7a48e-fc7c-499b-85a0-3fd6979f88f6」,:path =>「/ var/lib/logstash/uuid」} 14:58:14.308 [LogStash :: Runner] ERROR logstash。代理 - 無法在輸出\ n \ n {\ n \ n elasticsearch {\ n hosts「}後在第22行第9列(字節179)處創建管道{:reason =>」預期的#,=>} 2017-10 -11 14:58:14,355 Api Webserver錯誤未找到log4j2配置文件。使用默認配置:僅將錯誤記錄到控制檯。

+0

添加完所有ES主機條件後,請粘貼最終的logstash配置文件。 –

回答

0

試試這個。

output { 
    stdout { codec => rubydebug } 

    if [tag] == "templeton-math" { 
     elasticsearch { 
      hosts => ["elk.lera.com:80"] 
      index => "templeton-math-%{+YYYY.MM.dd}" 
     } 
    } 

    if [tag] == "templeton-science" { 
     elasticsearch { 
      hosts => ["elk.lera.com:80"] 
      index => "templeton-science-%{+YYYY.MM.dd}" 
     } 
    } 

    if [tag] == "templeton-bio" { 
     elasticsearch { 
      hosts => ["elk.lera.com:80"] 
      index => "templeton-bio-%{+YYYY.MM.dd}" 
     } 

    } 

    if [tag] == "templeton-lang" { 
     elasticsearch { 
      hosts => ["elk.lera.com:80"] 
      index => "templeton-lang-%{+YYYY.MM.dd}" 
     } 
    } 
}