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
| cp filebeat.yml filebeat.yml.bak && vim filebeat.yml
# 修改配置
filebeat.inputs:
#备注:日志有Error,warm,info,debug四种,所以每个服务要配置4个
- type: log
enable: true
paths:
#监控的文件路径
#- /opt/tools/elk/filebeat-8.6.0-linux-x86_64/data/registry/filebeat/*
- /opt/xxxService-1.0.0/bin/logs/**/*.log
#将自定义字段放在顶层发送
fields_under_root: true
#自定义字段
fields:
#本服务的ip
runip: x.x.x.x
#本服务的端口
runPort: xxxx
service_name: xxxService
#日志的编码格式
encoding: utf-8
#排除redis信息行
# exclude_lines: ['CSRedis','call method']
# 多行日志合并
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
multiline.negate: true
multiline.match: after
setup.ilm.enabled: false
setup.template.enabled: false
output.elasticsearch:
hosts: ["https://x.x.x.x:9200"]
username: "elastic"
password: "abc@123"
index: "tang-bg-%{[service_name]}-%{+yyyy.MM.dd}"
ssl.verification_mode: certificate
ssl.certificate_authorities: ["/opt/elk/elasticsearch-8.6.0/config/certs/http_ca.crt"]
pipline: "xxx-log"
processors:
- script:
lang: javascript
id: timestamp_filter
tag: enable
source: >
function process(event) {
var str= event.Get("message");
var time =str.substring(0, 23).replace(",",".");
event.Put("start_time",time);
}
- timestamp:
field: start_time
timezone: Asia/Shanghai
layouts:
- '2006-01-02 15:04:05'
- '2006-01-02 15:04:05.999'
test:
- '2019-06-22 16:33:51'
|