原始日志样例:
[2021-11-19T02:20:20.933Z] "POST /hu-api/mqttPush/checkLoginAuth HTTP/1.1" 200 - via_upstream "-" 0 80 2 2 "116.236.86.210" "okhttp/3.0.0" "6875420f-****-4c6a-ac36-dc5e22f1****" "**-gateway-center-uat.**.com" "10.26.*.184:8080" outbound|8080||**-gateway-center.****-uat.svc.cluster.local 10.26.*.95:41058 10.26.*.95:443 116.236.*.210:20905 *-gateway-center-uat.*.com - "-" "LSJA300000******"
正则表达式:
"\[(?P<start_time>[^\]]+)\]\s\\\"(?P<req_method>[^ ]+)\s(?P<req_x_envoy_original_path>[^\ ]+)\s(?P<protocol>[^\ ]+)\\\"\s(?P<response_code>[^\ ]+)\s(?P<response_flags>[^\\]+)\s+\\\"(?<RESPONSE_CODE_DETAILS>[^\\]+)\\\"\s+(?P<upstream_transport_fail_reason>\S+)\s+(?P<bytes_received>[^\ ]+)\s+(?P<bytes_sent>\S+)\s(?P<duration>\S+)\s+(?P<resp_x_envoy_upstream_svc_time>\S+)\s+\\\"(?P<req_x_forwarded_for>[^\\]+)\\\"\s+\\\"(?P<req_user_agent>[^\\]+)\\\"\s+\\\"(?P<req_x_request_id>[^\\]+)\\\"\s+\\\"(?P<req_authority>[^\\]+)\\\"\s+(?<upstream_host>[^\|]+)\|(?<upstream_cluster>[^\|]+)\|\|(?P<upstream_local_address>\S+)\s+(?P<downstream_local_address>\S+)\s+(?P<downstream_remote_address>\S+)\s+(?P<requested_server_name>\S+)\s(?P<route_name>[^\\"]+)\\\"(?<sn>[^\\"]+)\\\"\s+\\\"(?<vin>[^\\\"]+)\\\"\"
匹配结果:
本文来自博客园,作者:呱嗒呱嗒,转载请注明原文链接:https://www.cnblogs.com/auqiver/p/15576424.html