- A+
所属分类:ELKstack
在一个 logstash 中收集来多个 nginx 日志,有多个 type,可以使用 if 判断进行区分,输出到不同的 elasticsearch 中去。
- input {
- file {
- path => "/var/log/nginx/access.log"
- type => "nginx-access-log-node3"
- start_position => "beginning"
- stat_interval => "2"
- codec => "json"
- }
- file {
- path => "/var/log/messages"
- type => "system-log-node3"
- start_position => "beginning"
- stat_interval => "2"
- }
- }
- output {
- if [type] == "ginx-access-log-node3" {
- elasticsearch {
- hosts => ["192.168.56.31:9200"]
- index => "logstash-nginx-accesslog-node3-%{+YYYY.MM.dd}"
- }
- }
- if [type] == "system-log-node3" {
- elasticsearch {
- hosts => ["192.168.56.32:9200"]
- index => "logstash-system-log-node3-%{+YYYY.MM.dd}"
- }
- }
- }
2018年6月8日 下午4:40 沙发
1231