linux - Goaccess,格式错误 - 验证您的日志/日期/时间格式
问题描述
我尝试解析我的 nginx 日志文件,我的日志文件 mylog.log 如下
2021-06-29T08:48:47+00:00 "10.146.212.15" -> "mydns.com" - 0.000 5704 - - 4653 302 "68b069fb-6e8f-4a9c-88fd-8a947354b681" "GET /master HTTP/1.1"
2021-06-29T08:48:47+00:00 "10.146.212.15" -> "mydns.com" 0.006 0.006 726 855 337 621 302 "-" "GET /auth/admin/master/console HTTP/1.1"
我尝试使用命令“goaccess mylog.log --log-format=COMBINED --http-method=no --http-protocol=no -o output.html”来解析它
我收到此错误: ==1== 格式错误 - 验证您的日志/日期/时间格式
实际上:
'$time_iso8601 "$remote_addr" -> "$host" $upstream_response_time $request_time $request_length $upstream_bytes_sent $upstream_bytes_received $bytes_sent $status "$http_x_token_userid" "$request"'
解决方案
使用以下配置文件goaccess-nginx.conf
:
time-format %T
date-format %Y-%m-%d
log_format %dT%t+%^ "%h" -> "%v" %^ %T %^ %^ %D %b %s "%e" "%r"
# $time_iso8601 "$remote_addr" -> "$host" $upstream_response_time $request_time $request_length $upstream_bytes_sent $upstream_bytes_received $bytes_sent $status "$http_x_token_userid" "$request"
# 2021-06-29T08:48:47+00:00 "10.146.212.15" -> "mydns.com" - 0.000 5704 - - 4653 302 "68b069fb-6e8f-4a9c-88fd-8a947354b681" "GET /master HTTP/1.1"
# 2021-06-29T08:48:47+00:00 "10.146.212.15" -> "mydns.com" 0.006 0.006 726 855 337 621 302 "-" "GET /auth/admin/master/console HTTP/1.1"
您可以使用goaccess支持的所有自定义字段正确解析日志
goaccess --config-file goaccess-nginx.conf stackoverflow.log
如果你不想使用 goaccess 配置文件,你可以直接指定正确的参数作为标志:
goaccess --time-format %T --date-format %Y-%m-%d --log_format '%dT%t+%^ "%h" -> "%v" %^ %T %^ %^ %D %b %s "%e" "%r"' stackoverflow.log
推荐阅读
- javascript - 单击#item时避免div跳转到顶部
- r - dplyr 领先/落后于 group_by
- javascript - javascript 绑定函数未在第一次操作时触发
- javascript - 当时间动态时,相同的位置对于相同的 x、y、z 或 lat、long、height 显示不同
- php - 不使用 Artisan 链接存储文件夹
- windows - Anaconda中缺少graphlab安装依赖项
- sql - 为什么我们需要 SQL 中的“WHERE EXISTS”运算符?
- javascript - 使用 JQuery Click() 时无法传递事件
- java - 如何使用 Java 将 MongoDB 对象 ID 转换为 Java Date 或 Instant
- python - 列表迭代中的关键错误