Skip to content

Commit

Permalink
feat(access-log): omit empty fields in Envoy logs
Browse files Browse the repository at this point in the history
Signed-off-by: Abbas Gheydi <abbas.gheydi@gmail.com>
  • Loading branch information
abbas-gheydi committed Jan 13, 2024
1 parent 9070cfa commit 44d0cd8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/unreleased/6672-abbas-gheydi-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## **Access Log Enhancement**
Contour now omits empty fields in Envoy logs for the access log by default. This improves log clarity by excluding entries with empty values, providing a more concise and relevant log output. This behavior is not configurable, ensuring a streamlined experience for all users.
6 changes: 4 additions & 2 deletions internal/envoy/v3/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func FileAccessLogEnvoy(path string, format string, extensions []string, level c
},
},
},
Formatters: extensionConfig(extensions),
OmitEmptyValues: true,
Formatters: extensionConfig(extensions),
},
}
}
Expand Down Expand Up @@ -99,7 +100,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
5 changes: 5 additions & 0 deletions internal/envoy/v3/accesslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestFileAccessLog(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_TextFormatSource{
TextFormatSource: &envoy_config_core_v3.DataSource{
Specifier: &envoy_config_core_v3.DataSource_InlineString{
Expand All @@ -79,6 +80,7 @@ func TestFileAccessLog(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_TextFormatSource{
TextFormatSource: &envoy_config_core_v3.DataSource{
Specifier: &envoy_config_core_v3.DataSource_InlineString{
Expand Down Expand Up @@ -121,6 +123,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 @@ -151,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 +248,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 now includes a feature that, by default, omits empty fields in Envoy logs for the access log. This enhancement improves log clarity by excluding entries with empty values, providing a more concise and relevant log output. Please note that this behavior is set by default and is not configurable, ensuring a streamlined experience for all users.

#### Sample Configuration File

Here is a sample config:
Expand Down

0 comments on commit 44d0cd8

Please sign in to comment.