前面说了es,kibana的安装,其实他们的docker-compose可以写在一起,一起部署的,因为为了方便所以就分开了。
下面讲filebeat的安装和遇到的问题
1,安装公钥
sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
2,创建仓库地址文件,并写入配置文件
cd /etc/yum.repos.d/
vim elastic.repo
[elastic-8.x]
name=Elastic repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
3,安装命令
yum install filebeat
systemctl enable filebeat
- 修改filebeat配置文件
vim /etc/filebeat/filebeat.yml
配置路径
- type: log
id: test1
enabled: true
paths:
- /home/app/app.log
如果是自定义的json格式,则在paths后面添加以下
- type: log
id: test1
enabled: true
paths:
- /home/app/app.log
#json
json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true
fields_under_root: true
修改es地址
output.elasticsearch:
hosts: ["你的ip:9200"]
将日志的索引按照messge里面的内容进行分开
indices:
- index: "test1"
when.contains:
message: "test"
启动filebeat
systemctl start filebeat
问题汇总
- object mapping for [source] tried to parse field [source] as object
这是因为如果设置了自定义json的日志格式,则需要添加自定义的es模板,在页面上面创建新的index的模板,然后把自己的属性加上去就行了。