huhahapz 发表于 2018-11-10 07:34:18

logstash 过虑nginx访问日志

logstash#vi nginx_logs.conf  
input {
  
   file {
  
       type => "nginx-access"
  
       path => "/www/log/nginx/access/default.log"
  
       start_position => "beginning"
  
   }
  
}
  

  

  
filter {
  

  
if == "nginx-access" {
  
grok {
  
    match => { "message" => "%{NGINXACCESS}" }
  
}
  
date {
  
    match => [ "timestamp" , "dd/MMM/YYYY:HH:mm:ss Z" ]
  
}
  
geoip {
  
    source => "clientip"
  
    target => "geoip"
  
    database =>"/server/logstash/vendor/geoip/GeoLiteCity.dat"
  
    add_field => [ "", "%{}" ]
  
    add_field => [ "", "%{}"]
  

  
}
  
mutate {
  
    convert => [ "", "float" ]
  
}
  
}
  
}
  

  

  

  
output {
  

  

  
    redis {
  
      host => "10.252.35.170"
  
      port => 6379
  
      data_type => "list"
  
      key => "logstash"
  
    }
  
}


页: [1]
查看完整版本: logstash 过虑nginx访问日志