# cat filebeat.yml
filebeat.inputs:
- input_type: log
paths:
- /var/log/pods/*/*/*.log
# 以#开头的行不收集
exclude_lines: ['^#']
fields:
log_topic: "${TOPIC_ID}"
tail_files: true
clean_inactive: 48h
ignore_older: 24h
close_inactive: 1m
# 启动配置模块,该模块作用能将nginx\tomcat等日志转换为json模式,而无需再用logstash自已过滤匹配。
filebeat.config.modules:
# ${path.config}路径在/usr/share/filebeat/
# /usr/share/filebeat/modules.d/*.yml
path: ${path.config}/modules.d/*.yml
reload.enabled: true
########### 查看当前有哪些模块可以启用
./filebeat modules list
# 启动system/nginx/mysql模块,当启动模块后,会在/usr/share/filebeat/modules.d/目录下生成nginx.yml|system.yml|mysql.yml
./filebeat modules enable system nginx mysql
########### 在以下的模块配置中modules.d,更改模块设置以匹配您的环境。
# 在filebeat.yml配置filebeat.config.modules启动模块使用后,还需要在以下文件修改配置路径
官网参考: https://www.elastic.co/guide/en/beats/filebeat/7.9/filebeat-installation-configuration.html#setup-assets
cat /usr/share/filebeat/modules.d/nginx.yml
- module: nginx
access:
enabled: true
# 日志位置是根据操作系统设置的。如果您的日志不在默认位置,请设置paths变量:
var.paths: ["/var/log/nginx/access.log*"]
error:
enabled: true
var.paths: ["/var/log/nginx/access.log*"]
# 点击Visualize—搜索要查看的图形,我们搜索nginx, 模块提供了丰富的图形
# 模块方面可参考https://blog.csdn.net/weixin_44953658/article/details/118358918