Skip to content

Commit e02725c

Browse files
committed
fix: update promtail config to change access log path and optimize pipeline stages
1 parent 8c06f15 commit e02725c

File tree

1 file changed

+29
-41
lines changed

1 file changed

+29
-41
lines changed

promtail/config.yaml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,38 @@ scrape_configs:
1515
- localhost
1616
labels:
1717
job: nginx-access-log
18-
__path__: /var/log/nginx/access.log
18+
__path__: /var/log/nginx/api_access.log
1919
pipeline_stages:
2020
- match:
2121
selector: '{job="nginx-access-log"}'
22-
stages:
23-
- json: # 日志为json格式 选择需要的字段
24-
expressions:
25-
remote_addr:
26-
request_uri:
27-
verb:
28-
httpversion:
29-
response:
30-
body_bytes_sent:
31-
referrer:
32-
user_agent:
33-
http_x_forwarded_for:
34-
server_name:
35-
request_time:
36-
upstream_response_time:
37-
upstream_addr:
38-
realpath_root:
39-
cookie:
40-
nginx_version:
41-
scheme:
42-
time:
43-
- labels:
44-
remote_addr:
45-
request_uri:
46-
verb:
47-
httpversion:
48-
response:
49-
body_bytes_sent:
50-
referrer:
51-
user_agent:
52-
http_x_forwarded_for:
53-
server_name:
54-
request_time:
55-
upstream_response_time:
56-
upstream_addr:
57-
realpath_root:
58-
cookie:
59-
nginx_version:
60-
scheme:
61-
time:
22+
stages:
23+
- json: # 解析 JSON 格式的日志
24+
expressions:
25+
remote_addr:
26+
request_uri:
27+
verb:
28+
httpversion:
29+
response:
30+
body_bytes_sent:
31+
referrer:
32+
user_agent:
33+
http_x_forwarded_for:
34+
server_name:
35+
request_time:
36+
upstream_response_time:
37+
upstream_addr:
38+
realpath_root:
39+
cookie:
40+
nginx_version:
41+
scheme:
42+
time:
43+
44+
- labels: # 只选择低基数字段作为标签
45+
remote_addr:
46+
verb:
47+
response:
48+
server_name:
49+
scheme:
6250
- timestamp:
6351
format: '2006-01-02T15:04:05+08:00'
6452
source: time

0 commit comments

Comments
 (0)