@@ -250,7 +250,6 @@ func (m *MetricController) Run(ctx context.Context, mapOfTcpInfo *ebpf.Map) {
250250
251251 workloadLabels .reporter = "-"
252252 serviceLabels .reporter = "-"
253- accesslog .direction = "-"
254253 if data .direction == constants .INBOUND {
255254 workloadLabels .reporter = "destination"
256255 serviceLabels .reporter = "destination"
@@ -261,7 +260,7 @@ func (m *MetricController) Run(ctx context.Context, mapOfTcpInfo *ebpf.Map) {
261260 serviceLabels .reporter = "source"
262261 accesslog .direction = "OUTBOUND"
263262 }
264- if data .state == TCP_CLOSTED {
263+ if data .state == TCP_CLOSTED && accesslog . sourceWorkload != "-" {
265264 OutputAccesslog (data , accesslog )
266265 }
267266 m .mutex .Lock ()
@@ -350,6 +349,7 @@ func (m *MetricController) buildServiceMetric(data *requestMetric) (serviceMetri
350349 trafficLabels .requestProtocol = "tcp"
351350 trafficLabels .responseFlags = "-"
352351 trafficLabels .connectionSecurityPolicy = "mutual_tls"
352+
353353 accesslog .destinationAddress = dstIp + ":" + fmt .Sprintf ("%d" , data .dstPort )
354354 accesslog .sourceAddress = srcIp + ":" + fmt .Sprintf ("%d" , data .srcPort )
355355
@@ -361,8 +361,7 @@ func (m *MetricController) getWorkloadByAddress(address []byte) (*workloadapi.Wo
361361 networkAddr .Address , _ = netip .AddrFromSlice (address )
362362 workload := m .workloadCache .GetWorkloadByAddr (networkAddr )
363363 if workload == nil {
364- log .Debugf ("cannot find workload %s" , networkAddr .Address .String ())
365- return nil , ""
364+ return nil , networkAddr .Address .String ()
366365 }
367366 return workload , networkAddr .Address .String ()
368367}
@@ -399,7 +398,16 @@ func buildWorkloadMetric(dstWorkload, srcWorkload *workloadapi.Workload) workloa
399398
400399func buildServiceMetric (dstWorkload , srcWorkload * workloadapi.Workload , dstPort uint16 ) (serviceMetricLabels , logInfo ) {
401400 trafficLabels := serviceMetricLabels {}
402- accesslog := logInfo {}
401+ accesslog := logInfo {
402+ direction : "-" ,
403+ sourceAddress : "-" ,
404+ sourceWorkload : "-" ,
405+ sourceNamespace : "-" ,
406+ destinationAddress : "-" ,
407+ destinationService : "-" ,
408+ destinationWorkload : "-" ,
409+ destinationNamespace : "-" ,
410+ }
403411
404412 if dstWorkload != nil {
405413 namespacedhost := ""
@@ -437,8 +445,12 @@ func buildServiceMetric(dstWorkload, srcWorkload *workloadapi.Workload, dstPort
437445 trafficLabels .destinationPrincipal = buildPrincipal (dstWorkload )
438446
439447 accesslog .destinationWorkload = dstWorkload .Name
440- accesslog .destinationNamespace = svcNamespace
441- accesslog .destinationService = svcHost
448+ if svcNamespace != "" {
449+ accesslog .destinationNamespace = svcNamespace
450+ }
451+ if svcHost != "" {
452+ accesslog .destinationService = svcHost
453+ }
442454 }
443455
444456 if srcWorkload != nil {
0 commit comments