nginx logging to syslog using filebeat

nginx logging to syslog using filebeat

全文

http://nginx.org/en/docs/syslog.html

error_log 和 access_log指令都支持把日誌通過syslog發出去。這邊稍微記錄一下我的實踐。比較簡單。畢竟機器多了,一臺臺登錄分析是不大可能的。

error_log syslog:server=192.168.1.1 debug;

access_log syslog:server=unix:/var/log/nginx.sock,nohostname;
access_log syslog:server=[2001:db8::1]:12345,facility=local7,tag=nginx,severity=info combined;

關鍵發出去了,得有東西接受,我試了logstash的syslog 模塊,但是解析會有問題,<190> 這個沒法解析,後面換了filebeat 就支持的非常好,filebeat 的input和output還變多了,雖然是elastic公司出的,但是不只支持elasticsearch ,go寫的配置簡單而且佔用內存cpu都不高。

如果不指定端口,就是514端口,協議是udp的。需要注意一下。

filebeat 配置:

filebeat.inputs:
- type: syslog
  format: rfc3164
  protocol.udp:
    host: "localhost:9000"

output根據實際需要整就行了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章