vim filebeat.yml
filebeat.inputs:
#- type: log
# enabled: true
# paths:
# - /var/log/messages # 系统日志
# - /var/log/secure # 安全日志
# - /var/log/cron # 计划任务日志
# - /var/log/audit/audit.log # 审计日志
# tags: ["system-log"] # 添加标签,方便后续过滤
# fields:
# log_type: "system" # 自定义字段
# fields_under_root: true # 将自定义字段提升到根级别
- type: log
enabled: true
paths:
- /var/log/nginx/access.log
tags: ["nginx"]
fields:
log_type: "nginx"
fields_under_root: true # 将自定义字段提升到根级别
output.elasticsearch:
hosts: ["http://localhost:9200"]
indices:
# - index: "system-log-%{+yyyy.MM.dd}" # 自定义索引名称
# when.contains:
# tags: "system-log"
- index: "nginx-log-%{+yyyy.MM.dd}" # 自定义索引名称
when.contains:
tags: "nginx"
~