Skip to content

Commit

Permalink
Add grpc_status_code as a default access log field
Browse files Browse the repository at this point in the history
Fixes #4484

Signed-off-by: Rajat Vig <rvig@etsy.com>

Co-authored-by: Steve Kriss <stephen.kriss@gmail.com>
Signed-off-by: Rajat Vig <rvig@etsy.com>
  • Loading branch information
rajatvig and skriss committed Dec 15, 2022
1 parent 30320aa commit 46b6900
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions apis/projectcontour/v1alpha1/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var DefaultAccessLogJSONFields = AccessLogJSONFields([]string{
"user_agent",
"x_forwarded_for",
"grpc_status",
"grpc_status_number",
})

// DefaultAccessLogType is the default access log format.
Expand Down
2 changes: 2 additions & 0 deletions apis/projectcontour/v1alpha1/accesslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestValidateAccessLogJSONFields(t *testing.T) {
{"pod=%ENVIRONMENT(ENVOY_POD_NAME)%"},
{"dog=pug", "cat=black"},
{"grpc_status"},
{"grpc_status_number"},
}

for _, c := range successCases {
Expand Down Expand Up @@ -118,6 +119,7 @@ func TestAccessLogFormatString(t *testing.T) {
"queries %REQ_WITHOUT_QUERY(X-ENVOY-ORIGINAL-PATH?:PATH)% removed\n",
"just a string\n",
"%GRPC_STATUS%\n",
"%GRPC_STATUS_NUMBER%\n",
"%METADATA(ROUTE:com.test.my_filter:test_key):20%\n",
"%UPSTREAM_PROTOCOL%\n",
"%UPSTREAM_PEER_SUBJECT%\n",
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/4880-rajatvig-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `grpc_status_number` to the default JSON access log fields
1 change: 1 addition & 0 deletions cmd/contour/servecontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ func TestConvertServeContext(t *testing.T) {
"user_agent",
"x_forwarded_for",
"grpc_status",
"grpc_status_number",
}),
},
DefaultHTTPVersions: nil,
Expand Down
1 change: 1 addition & 0 deletions examples/contour/01-contour-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ data:
# - "user_agent"
# - "x_forwarded_for"
# - "grpc_status"
# - "grpc_status_number"
#
# default-http-versions:
# - "HTTP/2"
Expand Down
1 change: 1 addition & 0 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ data:
# - "user_agent"
# - "x_forwarded_for"
# - "grpc_status"
# - "grpc_status_number"
#
# default-http-versions:
# - "HTTP/2"
Expand Down
1 change: 1 addition & 0 deletions examples/render/contour-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ data:
# - "user_agent"
# - "x_forwarded_for"
# - "grpc_status"
# - "grpc_status_number"
#
# default-http-versions:
# - "HTTP/2"
Expand Down
1 change: 1 addition & 0 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ data:
# - "user_agent"
# - "x_forwarded_for"
# - "grpc_status"
# - "grpc_status_number"
#
# default-http-versions:
# - "HTTP/2"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ json-fields:
- user_agent
- x_forwarded_for
- grpc_status
- grpc_status_number
accesslog-level: info
timeouts:
connection-idle-timeout: 60s
Expand Down

0 comments on commit 46b6900

Please sign in to comment.