Skip to content

Commit 82f5530

Browse files
committed
style: format
1 parent 570dbeb commit 82f5530

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed

promtail/config.yaml

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,74 @@ clients:
99
- url: http://loki:3100/loki/api/v1/push
1010

1111
scrape_configs:
12-
- job_name: access
13-
static_configs:
14-
- targets:
15-
- localhost
16-
labels:
17-
job: nginx-access-log
18-
__path__: /var/log/nginx/api_access.log
19-
pipeline_stages:
20-
- match:
21-
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:
12+
- job_name: access
13+
static_configs:
14+
- targets:
15+
- localhost
16+
labels:
17+
job: nginx-access-log
18+
__path__: /var/log/nginx/api_access.log
19+
pipeline_stages:
20+
- match:
21+
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:
4343

44-
- labels: # 只选择低基数字段作为标签
44+
- labels: # 只选择低基数字段作为标签
4545
verb:
4646
response:
4747
server_name:
4848
scheme:
49-
- timestamp:
50-
format: '2006-01-02T15:04:05+08:00'
51-
source: time
52-
location: Asia/Shanghai
53-
54-
- job_name: nginx-error
55-
static_configs:
56-
- targets:
57-
- localhost
58-
labels:
59-
job: nginx-error-log
60-
__path__: /var/log/nginx/error.log
61-
pipeline_stages:
62-
- match:
63-
selector: '{job="nginx-error-log"}'
64-
stages:
65-
- regex: # 使用正则选择要提取的字段
66-
expression: '^(?P<timestamp>\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(?P<level>\S+)\] (?P<pid>\d+)#(?P<tid>\d+): \*(?P<cid>\d+) (?P<msg>.*) client: (?P<client_ip>[^,]+), server: (?P<server_name>[^,]+), request: "(?P<request_method>\S+) (?P<request_path>\S+) (?P<request_protocol>\S+)", upstream: "(?P<upstream>[^"]+)", host: "(?P<host>[^"]+)"$'
67-
- labels:
68-
level:
69-
pid:
70-
tid:
71-
cid:
72-
client_ip:
73-
server_name:
74-
request_method:
75-
request_path:
76-
request_protocol:
77-
upstream:
78-
host:
7949
- timestamp:
80-
format: "2006/01/02 15:04:05"
81-
source: time # 正则提取的字段
82-
location: Asia/Shanghai
50+
format: "2006-01-02T15:04:05+08:00"
51+
source: time
52+
location: Asia/Shanghai
53+
54+
- job_name: nginx-error
55+
static_configs:
56+
- targets:
57+
- localhost
58+
labels:
59+
job: nginx-error-log
60+
__path__: /var/log/nginx/error.log
61+
pipeline_stages:
62+
- match:
63+
selector: '{job="nginx-error-log"}'
64+
stages:
65+
- regex: # 使用正则选择要提取的字段
66+
expression: '^(?P<timestamp>\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(?P<level>\S+)\] (?P<pid>\d+)#(?P<tid>\d+): \*(?P<cid>\d+) (?P<msg>.*) client: (?P<client_ip>[^,]+), server: (?P<server_name>[^,]+), request: "(?P<request_method>\S+) (?P<request_path>\S+) (?P<request_protocol>\S+)", upstream: "(?P<upstream>[^"]+)", host: "(?P<host>[^"]+)"$'
67+
- labels:
68+
level:
69+
pid:
70+
tid:
71+
cid:
72+
client_ip:
73+
server_name:
74+
request_method:
75+
request_path:
76+
request_protocol:
77+
upstream:
78+
host:
79+
- timestamp:
80+
format: "2006/01/02 15:04:05"
81+
source: time # 正则提取的字段
82+
location: Asia/Shanghai

0 commit comments

Comments
 (0)