ELK + Filebeat 配置
目标架构
环境要求:安装jdk
硬件要求:4G内存,cpu核数至少2
示例版本:7.10.2
示例系统:linux
其他说明:
官网下载相同版本的elk和filebeat,注意,版本需保持一致
下载的文件解压缩即可使用
不能使用root启动,需要创建用户,并分配elk目录权限
elasticsearch.yml配置:
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
node.name: node-1
cluster.initial_master_nodes: ["node-1"]
启动命令:
./bin/elasticsearch &
kibana配置:
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
kibana.index: ".kibana"
启动命令:
./bin/kibana &
logstash配置:
input {
beats {
port => 5044
}
}
output {
if 'sgbGame' in [tags] {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "sgbgame-%{+YYYY.MM.dd}"
#index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "changeme"
}
}
else if 'slotGame' in [tags] {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "slotgame-%{+YYYY.MM.dd}"
#index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "changeme"
}
}
}
启动命令:
./bin/logstash -f config/logstash.conf &
filebeat配置:
filebeat.inputs:
- type: log
enabled: true
paths: "/usr/local/slot/logs/GameService/*"
tags: ["slotGame"]
- type: log
enabled: true
paths: "/usr/local/sgb/logs/GameService/*"
tags: ["sgbGame"]
output.logstash:
hosts: ["172.16.15.139:5044"]
topic: '%{[fields.log_topic]}'
processors:
- add_host_metadata: ~
- add_cloud_metadata: ~
启动命令:
./filebeat -e -c filebeat.yml &