From f5ca97b52cd0af9729cc4af2a7e023be11bc593c Mon Sep 17 00:00:00 2001 From: Abbas Gheydi Date: Fri, 19 Jan 2024 20:18:04 +0330 Subject: [PATCH 1/2] feat(access-log): omit empty fields in Envoy JOSN based logs Signed-off-by: Abbas Gheydi --- changelogs/unreleased/6077-abbas-gheydi-small.md | 1 + internal/envoy/v3/accesslog.go | 3 ++- internal/envoy/v3/accesslog_test.go | 3 +++ site/content/docs/main/config/access-logging.md | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/6077-abbas-gheydi-small.md diff --git a/changelogs/unreleased/6077-abbas-gheydi-small.md b/changelogs/unreleased/6077-abbas-gheydi-small.md new file mode 100644 index 00000000000..bfa20f6d79f --- /dev/null +++ b/changelogs/unreleased/6077-abbas-gheydi-small.md @@ -0,0 +1 @@ +Access Log: Contour excludes empty fields in Envoy JSON based access logs by default. diff --git a/internal/envoy/v3/accesslog.go b/internal/envoy/v3/accesslog.go index 094c911222c..7808bf32668 100644 --- a/internal/envoy/v3/accesslog.go +++ b/internal/envoy/v3/accesslog.go @@ -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), }, }, }), diff --git a/internal/envoy/v3/accesslog_test.go b/internal/envoy/v3/accesslog_test.go index bc6534758d2..e8b0b19318b 100644 --- a/internal/envoy/v3/accesslog_test.go +++ b/internal/envoy/v3/accesslog_test.go @@ -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{ @@ -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{ @@ -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{}, diff --git a/site/content/docs/main/config/access-logging.md b/site/content/docs/main/config/access-logging.md index f0e0676667e..4dcf20f6401 100644 --- a/site/content/docs/main/config/access-logging.md +++ b/site/content/docs/main/config/access-logging.md @@ -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 now 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: From 41461d9c2b03a41762ddae3d671711af63adb8e4 Mon Sep 17 00:00:00 2001 From: Abbas Gheydi Date: Tue, 23 Jan 2024 13:31:29 +0330 Subject: [PATCH 2/2] chore:remove 'now' from access log docs. Co-authored-by: Tero Saarni Signed-off-by: Abbas Gheydi --- site/content/docs/main/config/access-logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/docs/main/config/access-logging.md b/site/content/docs/main/config/access-logging.md index 4dcf20f6401..0c5b6e1583c 100644 --- a/site/content/docs/main/config/access-logging.md +++ b/site/content/docs/main/config/access-logging.md @@ -78,7 +78,7 @@ See the [example config file][6] to see this used in context. #### Omitting Logs with Empty Values -Contour now automatically omits empty fields in Envoy JSON access logs, enhancing clarity and delivering more concise and relevant log outputs by default. +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