Filebeat 配置参数详细说明,涵盖 input、prospector、output 各配置段。
1 2 3 4 5 6 7 8 9 10 11
| filebeat.prospectors: - input_type: log paths: - /var/log/*.log encoding: plain include_lines: ['^ERR', '^WARN'] exclude_lines: ['^DBG'] ignore_older: 5m document_type: log scan_frequency: 10s max_bytes: 10485760
|
多行匹配
1 2 3 4 5
| multiline.pattern: '^[' multiline.negate: false multiline.match: after multiline.max_lines: 500 multiline.timeout: 5s
|
2. 通用配置段
1 2 3 4 5
| name: filebeat tags: ["service-X"] fields: service: myservice fields_under_root: false
|
3. output.elasticsearch
1 2 3 4 5 6 7 8
| output.elasticsearch: hosts: ["localhost:9200"] index: "filebeat-%{+yyyy.MM.dd}" username: "elastic" password: "password" ssl.certificate_authorities: ["/path/to/ca.crt"] ssl.certificate: "/path/to/client.crt" ssl.key: "/path/to/client.key"
|
4. output.logstash
1 2 3 4 5
| output.logstash: hosts: ["localhost:5044"] loadbalance: true ssl.enabled: true ssl.certificate_authorities: ["/path/to/ca.crt"]
|
5. output.redis
1 2 3 4 5 6
| output.redis: hosts: ["localhost"] port: 6379 password: "password" db: 0 key: "filebeat"
|
6. Paths 配置段
1 2 3
| filebeat.config.paths: prospector: /etc/filebeat/conf.d/*.yml modules: /etc/filebeat/modules.d/*.yml
|
7. logging 配置段
1 2 3 4 5 6 7
| logging.level: info logging.to_files: true logging.files: path: /var/log/filebeat name: filebeat keepfiles: 7 permissions: 0644
|
常用完整配置示例
1 2 3 4 5 6 7 8 9 10 11 12
| filebeat.prospectors: - paths: - /var/log/nginx/*.log input_type: log document_type: nginx-access multiline.pattern: '^\d{4}-\d{2}-\d{2}' multiline.negate: true multiline.match: after
output.logstash: hosts: ["192.168.1.10:5044"] loadbalance: true
|