一个logstash上面收集多个日志配置参考2 min read

  • A+
所属分类:ELKstack

 

在一个 logstash 中收集来多个 nginx 日志,有多个 type,可以使用 if 判断进行区分,输出到不同的 elasticsearch 中去。

  1. input {  
  2.     file {  
  3.         path => "/var/log/nginx/access.log"  
  4.         type => "nginx-access-log-node3"  
  5.         start_position => "beginning"  
  6.         stat_interval => "2"  
  7.         codec => "json"  
  8.     }  
  9.     file {  
  10.         path => "/var/log/messages"  
  11.         type => "system-log-node3"  
  12.         start_position => "beginning"  
  13.         stat_interval => "2"  
  14.     }  
  15. }  
  16.   
  17. output {  
  18.     if [type] == "ginx-access-log-node3" {  
  19.         elasticsearch {  
  20.             hosts => ["192.168.56.31:9200"]  
  21.             index => "logstash-nginx-accesslog-node3-%{+YYYY.MM.dd}"  
  22.         }  
  23.     }  
  24.     if [type] == "system-log-node3" {  
  25.         elasticsearch {  
  26.             hosts => ["192.168.56.32:9200"]  
  27.             index => "logstash-system-log-node3-%{+YYYY.MM.dd}"  
  28.         }  
  29.     }  
  30. }  

  

  

zhaoyulin

发表评论取消回复

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  0   博主  0

    • zhaoyulin zhaoyulin Admin

      1231