这里先将日志直接通过 filebeat
输出到文件用于测试
log4j2配置日志输出
1
| %d{yyyyMMddHHmmssSSS}:%p [%T] [${pn}] [%X{cId}] [%X{cpId}] [%X{rTId}] %c{1.}(%L): %m%xwEx%n
|
%X{cId}
在java 中可以使用 ThreadContext.put("cId","test")
实现
filebeat.yml
配置
这里输出到日志文件测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| filebeat.inputs:
- type: filestream id: my-filestream-id enabled: true paths: - /data/test-log/*.log prospector.scanner.exclude_files: ['\.gz$'] parsers: - multiline: type: pattern pattern: '^\d' negate: true match: after timeout: 30s max_lines: 100
filebeat.config.modules: path: ${path.config}/modules.d/*.yml reload.enabled: true
setup.template.enabled: false setup.template.settings: index.number_of_shards: 1 setup.kibana:
output.elasticsearch: enabled: false output.logstash: enabled: false hosts: ["127.0.0.1:5044"] compression_level: 1 output.file: enabled: true path: "/data/filebeat" filename: filebeat rotate_every_kb: 10240 number_of_files: 7 permissions: 0600 rotate_on_startup: false
processors: - add_host_metadata: when.not.contains.tags: forwarded - add_cloud_metadata: ~ - add_docker_metadata: ~ - add_kubernetes_metadata: ~
|
multiline.pattern
表达式
本文地址: https://github.com/maxzhao-it/blog/post/374dd8da/