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

feat(access-log): omit empty fields in Envoy logs #6077

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/6077-abbas-gheydi-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Access Log: Contour excludes empty fields in Envoy JSON based access logs by default.
3 changes: 2 additions & 1 deletion internal/envoy/v3/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func FileAccessLogJSON(path string, fields contour_api_v1alpha1.AccessLogJSONFie
Format: &envoy_config_core_v3.SubstitutionFormatString_JsonFormat{
JsonFormat: jsonformat,
},
Formatters: extensionConfig(extensions),
OmitEmptyValues: true,
Formatters: extensionConfig(extensions),
},
},
}),
Expand Down
3 changes: 3 additions & 0 deletions internal/envoy/v3/accesslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func TestJSONFileAccessLog(t *testing.T) {
Path: "/dev/stdout",
AccessLogFormat: &envoy_file_v3.FileAccessLog_LogFormat{
LogFormat: &envoy_config_core_v3.SubstitutionFormatString{
OmitEmptyValues: true,
Format: &envoy_config_core_v3.SubstitutionFormatString_JsonFormat{
JsonFormat: &structpb.Struct{
Fields: map[string]*structpb.Value{
Expand Down Expand Up @@ -153,6 +154,7 @@ func TestJSONFileAccessLog(t *testing.T) {
Path: "/dev/stdout",
AccessLogFormat: &envoy_file_v3.FileAccessLog_LogFormat{
LogFormat: &envoy_config_core_v3.SubstitutionFormatString{
OmitEmptyValues: true,
Format: &envoy_config_core_v3.SubstitutionFormatString_JsonFormat{
JsonFormat: &structpb.Struct{
Fields: map[string]*structpb.Value{
Expand Down Expand Up @@ -244,6 +246,7 @@ func TestAccessLogLevel(t *testing.T) {
Path: "/dev/stdout",
AccessLogFormat: &envoy_file_v3.FileAccessLog_LogFormat{
LogFormat: &envoy_config_core_v3.SubstitutionFormatString{
OmitEmptyValues: true,
Format: &envoy_config_core_v3.SubstitutionFormatString_JsonFormat{
JsonFormat: &structpb.Struct{
Fields: map[string]*structpb.Value{},
Expand Down
4 changes: 4 additions & 0 deletions site/content/docs/main/config/access-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Note that the `DYNAMIC_METADATA` and `FILTER_STATE` Envoy logging operators are

See the [example config file][6] to see this used in context.

#### Omitting Logs with Empty Values

Contour automatically omits empty fields in Envoy JSON access logs, enhancing clarity and delivering more concise and relevant log outputs by default.

#### Sample Configuration File

Here is a sample config:
Expand Down