ELK结合redis或kafka收集日志

filebeat+redis+logstash

  • filebeat配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# filebeat-redis.yml
filebeat.inputs:
- type: log
enabled: true
backoff: "1s"
tail_files: false
paths:
- /var/log/nginx/access.log
fields:
filetype: nginx1
fields_under_root: true

output.redis:
enabled: true
hosts: ["10.90.25.20:6379"]
key: nginx
db: 0
password: xxzx@789
datatype: list
  • logstash配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# logstash-redis.conf
input {
redis {
host => "43.254.44.156"
port => 6379
password => "xxzx@789"
key => "nginx"
data_type => "list"
db => 0
}
}

filter {
grok {
match => { "message" => "%{HTTPD_COMBINEDLOG}" }
}

date {
match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]
target => "@timestamp"
}
}

output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "nginx-redis-%{+YYYY.MM.dd}"
}
}

filebeat+kafka+logstash

  • filebeat配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
filebeat.inputs:
- type: log
enabled: true
backoff: "1s"
tail_files: false
paths:
- /var/log/messages
fields:
filetype: kafka
fields_under_root: true

output.kafka:
enabled: true
hosts: ["10.57.22.170:9092"]
topic: liyk
  • logstash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
input {
kafka {
bootstrap_servers => "10.57.22.170:9092"
topics => ["liyk"]
group_id => "liyk_id"
}
}

output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "kafka-liyk"
}
}
-------------本文结束感谢您的阅读-------------
原创技术分享,感谢您的支持。