Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include own headers in envoy logs. #1734

Closed
cw-sakamoto opened this issue Oct 18, 2019 · 2 comments · Fixed by #1735
Closed

Include own headers in envoy logs. #1734

cw-sakamoto opened this issue Oct 18, 2019 · 2 comments · Fixed by #1735
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@cw-sakamoto
Copy link
Contributor

#1511 can export the envoy log in json format, but the corresponding items are hard-coated at https://github.com/projectcontour/contour/blob/master/internal/envoy/accesslog.go#L26-L49.

Isn't it possible to make JSONFields itself variable by writing config as shown below?

data:
  contour.yaml: |
    accesslog-format: json
    json-fields:
      "@timestamp":  "%START_TIME%",
      "ts":  "%START_TIME%",
      "authority":  "%REQ(:AUTHORITY)%",
      "bytes_received":  "%BYTES_RECEIVED%",
      "bytes_sent":   "%BYTES_SENT%",
      "downstream_local_address":  "%DOWNSTREAM_LOCAL_ADDRESS%",
      "downstream_remote_address": "%DOWNSTREAM_REMOTE_ADDRESS%",
      "duration":  "%DURATION%",
      "method":    "%REQ(:METHOD)%",
      "path":   "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%",
      "protocol":  "%PROTOCOL%",
      "request_id":  "%REQ(X-REQUEST-ID)%",
      "requested_server_name":  "%REQUESTED_SERVER_NAME%",
      "response_code":   "%RESPONSE_CODE%",
      "response_flags":   "%RESPONSE_FLAGS%",
      "uber_trace_id":   "%REQ(UBER-TRACE-ID)%",
      "upstream_cluster":  "%UPSTREAM_CLUSTER%",
      "upstream_host": "%UPSTREAM_HOST%",
      "upstream_local_address":  "%UPSTREAM_LOCAL_ADDRESS%",
      "upstream_service_time":   "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%",
      "user_agent":  "%REQ(USER-AGENT)%",
      "x_forwarded_for":  "%REQ(X-FORWARDED-FOR)%",
@davecheney
Copy link
Contributor

Isn't it possible to make JSONFields itself variable by writing config as shown below?

It is not possible, but if you can tell us the items you'd like to add to this map (or send a PR yourself), we're happy to add them.

https://github.com/projectcontour/contour/blob/master/internal/envoy/accesslog.go#L26

@davecheney davecheney added the blocked/needs-info Categorizes the issue or PR as blocked because there is insufficient information to advance it. label Oct 18, 2019
@cw-sakamoto
Copy link
Contributor Author

cw-sakamoto commented Oct 18, 2019

@davecheney
Thank you for the immediate reply!
x-trace-id is used internally. We confirmed that it can be obtained by adding as follows.

diff --git a/internal/envoy/accesslog.go b/internal/envoy/accesslog.go
index fddaeef..dd4a98f 100644
--- a/internal/envoy/accesslog.go
+++ b/internal/envoy/accesslog.go
@@ -46,6 +46,7 @@ var JSONFields = map[string]string{
        "upstream_service_time":     "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%",
        "user_agent":                "%REQ(USER-AGENT)%",
        "x_forwarded_for":           "%REQ(X-FORWARDED-FOR)%",
+       "x_trace_id":                "%REQ(X-TRACE-ID)%",
 }

@davecheney davecheney added kind/feature Categorizes issue or PR as related to a new feature. and removed blocked/needs-info Categorizes the issue or PR as blocked because there is insufficient information to advance it. labels Oct 20, 2019
@davecheney davecheney added this to the 1.0.0-rc.2 milestone Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants