From 004a7b7720cdcc1cb8e09e414ac64960e6c79c75 Mon Sep 17 00:00:00 2001 From: kongfei Date: Thu, 16 Mar 2023 17:29:00 +0800 Subject: [PATCH 1/2] more debug log and delete default include filter list --- logs/util/containers/filter.go | 2 -- logs/util/kubernetes/kubelet/kubelet.go | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/logs/util/containers/filter.go b/logs/util/containers/filter.go index e61f8c00..6464648c 100644 --- a/logs/util/containers/filter.go +++ b/logs/util/containers/filter.go @@ -236,12 +236,10 @@ func NewAutodiscoveryFilter(filter FilterType) (*Filter, error) { excludeList := coreconfig.GetContainerExcludeList() switch filter { case GlobalFilter: - includeList = []string{} if len(excludeList) == 0 { excludeList = append(excludeList, categrafContainer) } case LogsFilter: - includeList = []string{} if len(excludeList) == 0 { excludeList = append(excludeList, categrafContainer) } diff --git a/logs/util/kubernetes/kubelet/kubelet.go b/logs/util/kubernetes/kubelet/kubelet.go index 9a3128b0..c5c510db 100644 --- a/logs/util/kubernetes/kubelet/kubelet.go +++ b/logs/util/kubernetes/kubelet/kubelet.go @@ -217,6 +217,9 @@ func (ku *KubeUtil) GetLocalPodList(ctx context.Context) ([]*Pod, error) { allContainers = append(allContainers, pod.Status.Containers...) pod.Status.AllContainers = allContainers if !ku.filterPod(pod) { + if coreconfig.Config.DebugMode { + log.Printf("filter include, pod name: %s, pod namespace: %s. pod image:[%v]", pod.Metadata.Name, pod.Metadata.Namespace, pod.Spec.Containers) + } tmpSlice = append(tmpSlice, pod) } } @@ -231,10 +234,10 @@ func (ku *KubeUtil) GetLocalPodList(ctx context.Context) ([]*Pod, error) { func (ku *KubeUtil) filterPod(pod *Pod) bool { for _, c := range pod.Status.GetAllContainers() { - if coreconfig.Config.DebugMode { - log.Printf("D! container name:%s image:%s, ns:%s", c.Name, c.Image, pod.Metadata.Namespace) - } if ku.filter.IsExcluded(c.Name, c.Image, pod.Metadata.Namespace) { + if coreconfig.Config.DebugMode { + log.Printf("D! container name:%s image:%s, ns:%s, exclude:true", c.Name, c.Image, pod.Metadata.Namespace) + } return true } } From eeede05e8c9f5dc7cf891f59f5d58f4ddbf64bef Mon Sep 17 00:00:00 2001 From: kongfei Date: Thu, 16 Mar 2023 17:30:29 +0800 Subject: [PATCH 2/2] update debug log format --- logs/util/kubernetes/kubelet/kubelet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logs/util/kubernetes/kubelet/kubelet.go b/logs/util/kubernetes/kubelet/kubelet.go index c5c510db..63134852 100644 --- a/logs/util/kubernetes/kubelet/kubelet.go +++ b/logs/util/kubernetes/kubelet/kubelet.go @@ -218,7 +218,7 @@ func (ku *KubeUtil) GetLocalPodList(ctx context.Context) ([]*Pod, error) { pod.Status.AllContainers = allContainers if !ku.filterPod(pod) { if coreconfig.Config.DebugMode { - log.Printf("filter include, pod name: %s, pod namespace: %s. pod image:[%v]", pod.Metadata.Name, pod.Metadata.Namespace, pod.Spec.Containers) + log.Printf("D! filter include, pod name: %s, pod namespace: %s. pod image:[%v]", pod.Metadata.Name, pod.Metadata.Namespace, pod.Spec.Containers) } tmpSlice = append(tmpSlice, pod) }