elk 监控nginx php日志
1,logstash服务端配置
input {
beats {
port => 5044
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
template_overwrite => true
}
stdout{codec => rubydebug}
}
在这里,我没有设置过滤器,如果不设置,会把指定日志文件的内容全部读取出来。如果要进行这种配置,监控的php,Nginx都要是单独的日志,并且如果一台机器有多个网站,设置多个不同的php日志文件,这样通过file设置的类型,以及内容,来区分不同网站的日志。
2,filebeat客户端配置
$ cat filebeat.yml
filebeat:
prospectors:
- //注意横线
paths:
- /var/log/Nginx/*error.log
- /var/log/Nginx/*error.log.1
document_type: Nginxlive
input_type: log
- //注意横线
paths:
- /var/log/php/*errors.log
- /var/www/42cc.admin.leo1v1.com/storage/logs/*.log
- /var/www/42admin.leo1v1.com/storage/logs/*.log
- /var/www/42cr.admin.leo1v1.com/storage/logs/*.log
- /var/www/42market.admin.leo1v1.com/storage/logs/*.log
document_type: phplive
input_type: log
registry_file: /var/lib/filebeat/registry
output:
logstash:
hosts: ["192.168.0.123:5044"]
bulk_max_size: 10240
shipper:
logging:
files:
rotateeverybytes: 10485760 # = 10MB
重启logstash和filebeat就可以了