Skip to content

Commit

Permalink
Merge pull request #414 from kongfei605/logs_filter
Browse files Browse the repository at this point in the history
more debug log and delete default include filter list
  • Loading branch information
kongfei605 authored Mar 16, 2023
2 parents 5544402 + eeede05 commit 08e62eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions logs/util/containers/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 6 additions & 3 deletions logs/util/kubernetes/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("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)
}
}
Expand All @@ -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
}
}
Expand Down

0 comments on commit 08e62eb

Please sign in to comment.