0

运行脚本时,我收到所有失败的请求。我最初写出 JSON 以匹配日志文件。但是,在 goaccess 中调试时,JSON 的顺序并不相同。它的顺序类似于下面我的配置文件中的日志格式。

这是我的配置文件详细信息

time-format %T
date-format %d/%b/%Y
log-format '{"sent_x_cache":"%^","http_x_forwarded_for":"%^","%^","request_url":"%U","timestamp":"%d:%t %^","request_id":"%^","remote_address":"%h","remote_user":"%^","http_accept_language":"%^","http_version":"%H","body_bytes_sent":"%^","request_type":"%m","upstream_country_code":"%^","request_time":"%T","scheme":"%^","client_site_id":"%^","http_referer":"%R","http_user_agent":"%u","private_file":"%^","asn":"%^","http_host":"%v","wplogin":"%^","ssl_client_verify":"%^","sent_cache_control":"%^","status":"%s","sent_vary":"%^","content_type":"%M","tls_version":"%^","timestamp_iso8601":"%^","true_client_ip":"%^",}'

例子

{"remote_addr":"55.555.55.555",
"remote_user":"",
"http_accept_language":"",
"http_version":"HTTP/1.1",
"request_url":"/example/example/",
"request_id":"11111111111111111111",
"body_bytes_sent":"1111",
"request_type":"GET",
"upstream_country_code":"UK",
"request_time":"0.011",
"scheme":"https",
"client_site_id":"1111",
"http_referer":"",
"http_user_agent":"Mozilla/5.0 (Linux)",
"private_file":"",
"asn":"11111",
"http_host":"example.example.com",
"ssl_client_verify":"NONE",
"sent_cache_control":"max-age=100, must-revalidate",
"status":"200",
"sent_vary":"Accept-Encoding",
"content_type":"text/html; charset=UTF-8",
"sent_x_cache":"hit",
"tls_version":"TLSv1.1",
"timestamp":"11/Jan/2022:11:11:11 +0000",
"timestamp_iso8601":"2022-01-11T11:11:11+00:00",
"http_x_forwarded_for":""}

我在 Ubuntu 20.04 LTS 中运行的脚本

zcat 1_*.gz | /home/ubuntu/goaccess/./goaccess -p goaccess_nginx_log.conf -access.log

4

0 回答 0