【发布时间】:2016-01-21 01:37:23
【问题描述】:
我有一个 nginx 自定义日志文件,类似于:
{ "timestamp": "2015-12-20T12:30:40+03:30", "remote_addr": "80.253.148.194", "remote_user": "-", "body_bytes_sent": "0", "request_time": "0.000", "status": "304", "request": "GET /repository/9/13350-000036.png HTTP/1.1", "request_method": "GET", "http_referrer": "http://domain.ltd/profile/category/1425", "http_user_agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0" }
{ "timestamp": "2015-12-20T12:30:40+03:30", "remote_addr": "80.253.148.194", "remote_user": "-", "body_bytes_sent": "0", "request_time": "0.000", "status": "304", "request": "GET /repository/9/13349-000018.png HTTP/1.1", "request_method": "GET", "http_referrer": "http://domain.ltd/profile/category/1425", "http_user_agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0" }
{ "timestamp": "2015-12-20T12:27:24+03:30", "remote_addr": "79.175.174.23", "remote_user": "-", "body_bytes_sent": "139008", "request_time": "0.298", "status": "206", "request": "GET /repository/9/56766da1202f7.mp4 HTTP/1.1", "request_method": "GET", "http_referrer": "-", "http_user_agent": "Lavf/56.4.101" }...
它包含 3792061 行。
我已经设置了日志格式并且工作正常,但是在工作完成后,会丢失一些数据,比如报告中没有/9/ 文件。
HERE 是我的 goaccess 报告。
我的命令是:
# goaccess -o json --static-file=.mp4 --static-file=.MP4 --ignore-panel=VISITORS --ignore-panel=REQUESTS --ignore-panel=NOT_FOUND --ignore-panel=HOSTS --ignore-panel=OS --ignore-panel=BROWSERS --ignore-panel=VISIT_TIMES --ignore-panel=VIRTUAL_HOSTS --ignore-panel=REFERRERS --ignore-panel=REFERRING_SITES --ignore-panel=KEYPHRASES --ignore-panel=GEO_LOCATION --ignore-panel=STATUS_CODES --sort-panel=REQUESTS_STATIC,BY_BW,DESC --debug-file debug.log --invalid-requests invalid.log -f ./access.json > data.json
无效请求文件有 40 行,可忽略。
但后来我拆分了我的文件并找到了 /9/ 的行 # cat access.json | fgrep '/9/' ./access.json > newlog.json
我在 goaccess 中为此日志执行完全相同的命令,我得到 This 输出,这很好。
卡在那里,感谢任何帮助
【问题讨论】: