前言
前几天部署了elk日志分析系统,就想將所有服务器的登录日志统一分析。边使用边熟悉各个模块的配置
filebeat
hostname:区分不同的主机
volumes:需要传输的日志文件映射到容器内
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /log/secure
  fields:
    log_type: secure
output.logstash:
  hosts: ["49.12.10.10:5044"]
  enabled: true
  worker: 1
  compression_level: 3
  loadbalance: true
docker-compose up -d
logstash
input {
  beats {
    port => 5044
  }
}
filter {
    grok {
      match => { "message" => ".*sshd\[\d+\]: %{WORD:status} .* %{USER:username} from.*%{IP:clientip}.*" }
    }
}
output {
 if ([status] == "Accepted" or [status] == "Failed") {
  elasticsearch {
   hosts => [ "es-master:9200" ]
   index => "secure-%{+YYYY.MM.dd}"
   }
  stdout {
   codec => rubydebug
  }
 }
}
kibana
            
                     
elk 的模板能分享下吗