@@ -23,8 +23,6 @@ import (
2323 fileaccesslog "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/file/v3"
2424 grpcaccesslog "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3"
2525 otelaccesslog "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/open_telemetry/v3"
26- celformatter "github.com/envoyproxy/go-control-plane/envoy/extensions/formatter/cel/v3"
27- metadataformatter "github.com/envoyproxy/go-control-plane/envoy/extensions/formatter/metadata/v3"
2826 reqwithoutquery "github.com/envoyproxy/go-control-plane/envoy/extensions/formatter/req_without_query/v3"
2927 otlpcommon "go.opentelemetry.io/proto/otlp/common/v1"
3028 "google.golang.org/protobuf/types/known/structpb"
@@ -119,20 +117,6 @@ var (
119117 Name : "envoy.formatter.req_without_query" ,
120118 TypedConfig : protoconv .MessageToAny (& reqwithoutquery.ReqWithoutQuery {}),
121119 }
122-
123- // metadataFormatter configures additional formatters needed for some of the format strings like "METADATA"
124- // for more information, see https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/formatter/metadata/v3/metadata.proto
125- metadataFormatter = & core.TypedExtensionConfig {
126- Name : "envoy.formatter.metadata" ,
127- TypedConfig : protoconv .MessageToAny (& metadataformatter.Metadata {}),
128- }
129-
130- // celFormatter configures additional formatters needed for some of the format strings like "CEL"
131- // for more information, see https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/formatter/cel/v3/cel.proto
132- celFormatter = & core.TypedExtensionConfig {
133- Name : "envoy.formatter.cel" ,
134- TypedConfig : protoconv .MessageToAny (& celformatter.Cel {}),
135- }
136120)
137121
138122// configureFromProviderConfigHandled contains the number of providers we handle below.
@@ -141,27 +125,22 @@ var (
141125const telemetryAccessLogHandled = 15
142126
143127func telemetryAccessLog (push * PushContext , proxy * Proxy , fp * meshconfig.MeshConfig_ExtensionProvider ) * accesslog.AccessLog {
144- // Skip built-in formatter if Istio version is >= 1.26
145- // This is because if we send CEL/METADATA in the access log,
146- // envoy will report lots of warn message endlessly.
147- skipBuiltInFormatter := proxy .IstioVersion != nil && proxy .VersionGreaterOrEqual (& IstioVersion {Major : 1 , Minor : 26 })
148-
149128 var al * accesslog.AccessLog
150129 switch prov := fp .Provider .(type ) {
151130 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLog :
152131 // For built-in provider, fallback to MeshConfig for formatting options when LogFormat unset.
153132 if fp .Name == builtinEnvoyAccessLogProvider &&
154133 prov .EnvoyFileAccessLog .LogFormat == nil && ! prov .EnvoyFileAccessLog .OmitEmptyValues {
155- al = FileAccessLogFromMeshConfig (prov .EnvoyFileAccessLog .Path , push .Mesh , skipBuiltInFormatter )
134+ al = FileAccessLogFromMeshConfig (prov .EnvoyFileAccessLog .Path , push .Mesh )
156135 } else {
157- al = fileAccessLogFromTelemetry (prov .EnvoyFileAccessLog , skipBuiltInFormatter )
136+ al = fileAccessLogFromTelemetry (prov .EnvoyFileAccessLog )
158137 }
159138 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyHttpAls :
160139 al = httpGrpcAccessLogFromTelemetry (push , proxy , prov .EnvoyHttpAls )
161140 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyTcpAls :
162141 al = tcpGrpcAccessLogFromTelemetry (push , proxy , prov .EnvoyTcpAls )
163142 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyOtelAls :
164- al = openTelemetryLog (push , proxy , prov .EnvoyOtelAls , skipBuiltInFormatter )
143+ al = openTelemetryLog (push , proxy , prov .EnvoyOtelAls )
165144 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyExtAuthzHttp ,
166145 * meshconfig.MeshConfig_ExtensionProvider_EnvoyExtAuthzGrpc ,
167146 * meshconfig.MeshConfig_ExtensionProvider_Zipkin ,
@@ -231,7 +210,7 @@ func tcpGrpcAccessLogFromTelemetry(push *PushContext, proxy *Proxy,
231210 }
232211}
233212
234- func fileAccessLogFromTelemetry (prov * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLogProvider , skipBuiltInFormatter bool ) * accesslog.AccessLog {
213+ func fileAccessLogFromTelemetry (prov * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLogProvider ) * accesslog.AccessLog {
235214 p := prov .Path
236215 if p == "" {
237216 p = DevStdout
@@ -244,12 +223,12 @@ func fileAccessLogFromTelemetry(prov *meshconfig.MeshConfig_ExtensionProvider_En
244223 if prov .LogFormat != nil {
245224 switch logFormat := prov .LogFormat .LogFormat .(type ) {
246225 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLogProvider_LogFormat_Text :
247- fl .AccessLogFormat , needsFormatter = buildFileAccessTextLogFormat (logFormat .Text , prov .OmitEmptyValues , skipBuiltInFormatter )
226+ fl .AccessLogFormat , needsFormatter = buildFileAccessTextLogFormat (logFormat .Text , prov .OmitEmptyValues )
248227 case * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLogProvider_LogFormat_Labels :
249- fl .AccessLogFormat , needsFormatter = buildFileAccessJSONLogFormat (logFormat , prov .OmitEmptyValues , skipBuiltInFormatter )
228+ fl .AccessLogFormat , needsFormatter = buildFileAccessJSONLogFormat (logFormat , prov .OmitEmptyValues )
250229 }
251230 } else {
252- fl .AccessLogFormat , needsFormatter = buildFileAccessTextLogFormat ("" , prov .OmitEmptyValues , skipBuiltInFormatter )
231+ fl .AccessLogFormat , needsFormatter = buildFileAccessTextLogFormat ("" , prov .OmitEmptyValues )
253232 }
254233 if len (needsFormatter ) != 0 {
255234 fl .GetLogFormat ().Formatters = needsFormatter
@@ -264,10 +243,10 @@ func fileAccessLogFromTelemetry(prov *meshconfig.MeshConfig_ExtensionProvider_En
264243}
265244
266245func buildFileAccessTextLogFormat (
267- logFormatText string , omitEmptyValues bool , skipBuiltInFormatter bool ,
246+ logFormatText string , omitEmptyValues bool ,
268247) (* fileaccesslog.FileAccessLog_LogFormat , []* core.TypedExtensionConfig ) {
269248 formatString := fileAccessLogFormat (logFormatText )
270- formatters := accessLogTextFormatters (formatString , skipBuiltInFormatter )
249+ formatters := accessLogTextFormatters (formatString )
271250
272251 return & fileaccesslog.FileAccessLog_LogFormat {
273252 LogFormat : & core.SubstitutionFormatString {
@@ -285,7 +264,7 @@ func buildFileAccessTextLogFormat(
285264
286265func buildFileAccessJSONLogFormat (
287266 logFormat * meshconfig.MeshConfig_ExtensionProvider_EnvoyFileAccessLogProvider_LogFormat_Labels ,
288- omitEmptyValues bool , skipBuiltInFormatter bool ,
267+ omitEmptyValues bool ,
289268) (* fileaccesslog.FileAccessLog_LogFormat , []* core.TypedExtensionConfig ) {
290269 jsonLogStruct := EnvoyJSONLogFormatIstio
291270 if logFormat .Labels != nil {
@@ -297,7 +276,7 @@ func buildFileAccessJSONLogFormat(
297276 jsonLogStruct = EnvoyJSONLogFormatIstio
298277 }
299278
300- formatters := accessLogJSONFormatters (jsonLogStruct , skipBuiltInFormatter )
279+ formatters := accessLogJSONFormatters (jsonLogStruct )
301280 return & fileaccesslog.FileAccessLog_LogFormat {
302281 LogFormat : & core.SubstitutionFormatString {
303282 Format : & core.SubstitutionFormatString_JsonFormat {
@@ -309,50 +288,31 @@ func buildFileAccessJSONLogFormat(
309288 }, formatters
310289}
311290
312- func accessLogJSONFormatters (jsonLogStruct * structpb.Struct , skipBuiltInFormatter bool ) []* core.TypedExtensionConfig {
291+ func accessLogJSONFormatters (jsonLogStruct * structpb.Struct ) []* core.TypedExtensionConfig {
313292 if jsonLogStruct == nil {
314293 return nil
315294 }
316295
317- reqWithoutQuery , metadata , cel := false , false , false
296+ reqWithoutQuery := false
318297 for _ , value := range jsonLogStruct .Fields {
319298 if ! reqWithoutQuery && strings .Contains (value .GetStringValue (), reqWithoutQueryCommandOperator ) {
320299 reqWithoutQuery = true
321300 }
322- if ! skipBuiltInFormatter && ! metadata && strings .Contains (value .GetStringValue (), metadataCommandOperator ) {
323- metadata = true
324- }
325- if ! skipBuiltInFormatter && ! cel && strings .Contains (value .GetStringValue (), celCommandOperator ) {
326- cel = true
327- }
328301 }
329302
330303 formatters := make ([]* core.TypedExtensionConfig , 0 , maxFormattersLength )
331304 if reqWithoutQuery {
332305 formatters = append (formatters , reqWithoutQueryFormatter )
333306 }
334- if metadata {
335- formatters = append (formatters , metadataFormatter )
336- }
337- if cel {
338- formatters = append (formatters , celFormatter )
339- }
340307
341308 return formatters
342309}
343310
344- func accessLogTextFormatters (text string , skipBuiltInFormatter bool ) []* core.TypedExtensionConfig {
311+ func accessLogTextFormatters (text string ) []* core.TypedExtensionConfig {
345312 formatters := make ([]* core.TypedExtensionConfig , 0 , maxFormattersLength )
346313 if strings .Contains (text , reqWithoutQueryCommandOperator ) {
347314 formatters = append (formatters , reqWithoutQueryFormatter )
348315 }
349- // Start from Istio 1.26+(envoy 1.34), the formatter ``%CEL%`` and ``%METADATA%`` will be treated as built-in formatters
350- if ! skipBuiltInFormatter && strings .Contains (text , metadataCommandOperator ) {
351- formatters = append (formatters , metadataFormatter )
352- }
353- if ! skipBuiltInFormatter && strings .Contains (text , celCommandOperator ) {
354- formatters = append (formatters , celFormatter )
355- }
356316
357317 return formatters
358318}
@@ -415,7 +375,7 @@ func fileAccessLogFormat(formatString string) string {
415375 return EnvoyTextLogFormat
416376}
417377
418- func FileAccessLogFromMeshConfig (path string , mesh * meshconfig.MeshConfig , skipBuiltInFormatter bool ) * accesslog.AccessLog {
378+ func FileAccessLogFromMeshConfig (path string , mesh * meshconfig.MeshConfig ) * accesslog.AccessLog {
419379 // We need to build access log. This is needed either on first access or when mesh config changes.
420380 fl := & fileaccesslog.FileAccessLog {
421381 Path : path ,
@@ -424,7 +384,7 @@ func FileAccessLogFromMeshConfig(path string, mesh *meshconfig.MeshConfig, skipB
424384 switch mesh .AccessLogEncoding {
425385 case meshconfig .MeshConfig_TEXT :
426386 formatString := fileAccessLogFormat (mesh .AccessLogFormat )
427- formatters = accessLogTextFormatters (formatString , skipBuiltInFormatter )
387+ formatters = accessLogTextFormatters (formatString )
428388 fl .AccessLogFormat = & fileaccesslog.FileAccessLog_LogFormat {
429389 LogFormat : & core.SubstitutionFormatString {
430390 Format : & core.SubstitutionFormatString_TextFormatSource {
@@ -446,7 +406,7 @@ func FileAccessLogFromMeshConfig(path string, mesh *meshconfig.MeshConfig, skipB
446406 jsonLogStruct = & parsedJSONLogStruct
447407 }
448408 }
449- formatters = accessLogJSONFormatters (jsonLogStruct , skipBuiltInFormatter )
409+ formatters = accessLogJSONFormatters (jsonLogStruct )
450410 fl .AccessLogFormat = & fileaccesslog.FileAccessLog_LogFormat {
451411 LogFormat : & core.SubstitutionFormatString {
452412 Format : & core.SubstitutionFormatString_JsonFormat {
@@ -471,7 +431,7 @@ func FileAccessLogFromMeshConfig(path string, mesh *meshconfig.MeshConfig, skipB
471431}
472432
473433func openTelemetryLog (pushCtx * PushContext , proxy * Proxy ,
474- provider * meshconfig.MeshConfig_ExtensionProvider_EnvoyOpenTelemetryLogProvider , skipBuiltInFormatter bool ,
434+ provider * meshconfig.MeshConfig_ExtensionProvider_EnvoyOpenTelemetryLogProvider ,
475435) * accesslog.AccessLog {
476436 hostname , cluster , err := clusterLookupFn (pushCtx , provider .Service , int (provider .Port ))
477437 if err != nil {
@@ -495,7 +455,7 @@ func openTelemetryLog(pushCtx *PushContext, proxy *Proxy,
495455 labels = provider .LogFormat .Labels
496456 }
497457
498- cfg := buildOpenTelemetryAccessLogConfig (proxy , logName , hostname , cluster , f , labels , skipBuiltInFormatter )
458+ cfg := buildOpenTelemetryAccessLogConfig (proxy , logName , hostname , cluster , f , labels )
499459
500460 return & accesslog.AccessLog {
501461 Name : OtelEnvoyALSName ,
@@ -504,7 +464,7 @@ func openTelemetryLog(pushCtx *PushContext, proxy *Proxy,
504464}
505465
506466func buildOpenTelemetryAccessLogConfig (proxy * Proxy ,
507- logName , hostname , clusterName , format string , labels * structpb.Struct , skipBuiltInFormatter bool ,
467+ logName , hostname , clusterName , format string , labels * structpb.Struct ,
508468) * otelaccesslog.OpenTelemetryAccessLogConfig {
509469 cfg := & otelaccesslog.OpenTelemetryAccessLogConfig {
510470 CommonConfig : & grpcaccesslog.CommonGrpcAccessLogConfig {
@@ -537,20 +497,20 @@ func buildOpenTelemetryAccessLogConfig(proxy *Proxy,
537497 }
538498 }
539499
540- cfg .Formatters = accessLogFormatters (format , labels , skipBuiltInFormatter )
500+ cfg .Formatters = accessLogFormatters (format , labels )
541501
542502 return cfg
543503}
544504
545- func accessLogFormatters (text string , labels * structpb.Struct , skipBuiltInFormatter bool ) []* core.TypedExtensionConfig {
505+ func accessLogFormatters (text string , labels * structpb.Struct ) []* core.TypedExtensionConfig {
546506 formatters := make ([]* core.TypedExtensionConfig , 0 , maxFormattersLength )
547507 defer func () {
548508 slices .SortBy (formatters , func (f * core.TypedExtensionConfig ) string {
549509 return f .Name
550510 })
551511 }()
552512
553- formatters = append (formatters , accessLogTextFormatters (text , skipBuiltInFormatter )... )
513+ formatters = append (formatters , accessLogTextFormatters (text )... )
554514 if len (formatters ) >= maxFormattersLength {
555515 // all formatters are added, return if we have reached the limit
556516 return formatters
@@ -561,7 +521,7 @@ func accessLogFormatters(text string, labels *structpb.Struct, skipBuiltInFormat
561521 names .Insert (f .Name )
562522 }
563523
564- for _ , f := range accessLogJSONFormatters (labels , skipBuiltInFormatter ) {
524+ for _ , f := range accessLogJSONFormatters (labels ) {
565525 if ! names .Contains (f .Name ) {
566526 formatters = append (formatters , f )
567527 names .Insert (f .Name )
0 commit comments