Skip to content

queue-proxy:Invalid request log template #15981

@liuyuxuan0723

Description

@liuyuxuan0723

What version of Knative?

1.11.2

Expected Behavior

Configured the request logging template following https://knative.dev/docs/serving/observability/logging/request-logging/

logging.request-log-template: >-
    {"requestMethod": "{{.Request.Method}}", "requestUrl": "{{js
    .Request.RequestURI}}", "requestSize": {{.Request.ContentLength}}, "code":
    {{.Response.Code}}, "responseSize": {{.Response.Size}}, "userAgent": "{{js
    .Request.UserAgent}}", "remoteIp": "{{js .Request.RemoteAddr}}", "serverIp":
    "{{.Revision.PodIP}}", "referer": "{{js .Request.Referer}}", "latency":
    {{.Response.Latency}}, "protocol": "{{.Request.Proto}}", "traceID": "{{index
    (index .Request.Header "X-B3-Traceid") 0}}","msg":"Finished handling
    request."}

Expected to output trace ID in the request logs:

{"requestMethod": "POST", "requestUrl": "/", "requestSize": 559, "code": 200, "responseSize": 27, "userAgent": "go-resty/2.16.5 (https://github.com/go-resty/resty)", "remoteIp": "10.36.180.90:53598", "serverIp": "10.36.134.94", "referer": "", "latency": 6.950939235, "protocol": "HTTP/1.1", "traceID": "012bf535a144fa584d40fe791b04ce18","msg":"Finished handling request."}

Actual Behavior

During traffic spikes, some request logs fail to parse according to the template and show the following error. I confirmed that every request comes from the same client and includes the X-B3-Traceid header.

{"requestMethod": "POST", "requestUrl": "/", "requestSize": 560, "code": 200, "responseSize": 27, "userAgent": "go-resty/2.16.5 (https://github.com/go-resty/resty)", "remoteIp": "10.36.183.136:42866", "serverIp": "10.36.178.75", "referer": "", "latency": 0.070215634, "protocol": "HTTP/1.1", "traceID": "Invalid request log template: method: POST, response code: 200, latency: 0.098454743, url: /

Steps to Reproduce the Problem

This occurs with some probability every time there's a traffic spike, but the root cause is uncertain.

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.triage/needs-user-inputIssues which are waiting on a response from the reporter

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions