Skip to content

Commit

Permalink
Fix namespace filter.
Browse files Browse the repository at this point in the history
Signed-off-by: constanca <[email protected]>
  • Loading branch information
constanca-m committed Jun 19, 2024
1 parent 4a281d7 commit 1df9175
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions metricbeat/docs/modules/kubernetes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ metricbeat.modules:
# When used outside the cluster:
#node: node_name
# Set the namespace to watch for resources
# Set the namespace to add metadata
#namespace: staging
# To configure additionally node and namespace metadata `add_resource_metadata` can be defined.
# By default all labels will be included while annotations are not added by default.
# By default, all labels will be included while annotations are not added by default.
# add_resource_metadata:
# namespace:
# include_labels: ["namespacelabel1"]
Expand All @@ -326,7 +326,7 @@ metricbeat.modules:
# If kube_config is not set, KUBECONFIG environment variable will be checked
# and if not present it will fall back to InCluster
#kube_config: ~/.kube/config
# Set the namespace to watch for events
# Set the namespace to add metadata
#namespace: staging
# Set the sync period of the watchers
#sync_period: 10m
Expand Down
8 changes: 4 additions & 4 deletions metricbeat/module/kubernetes/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"

kubernetes2 "github.com/elastic/beats/v7/libbeat/autodiscover/providers/kubernetes"
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/elastic-agent-autodiscover/kubernetes"
"github.com/elastic/elastic-agent-autodiscover/kubernetes/metadata"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"

kubernetes2 "github.com/elastic/beats/v7/libbeat/autodiscover/providers/kubernetes"
"github.com/elastic/beats/v7/metricbeat/mb"
)

type kubernetesConfig struct {
Expand Down Expand Up @@ -281,8 +282,7 @@ func getWatchOptions(config *kubernetesConfig, nodeScope bool, client k8sclient.
}

func isNamespaced(resourceName string) bool {
if resourceName == NodeResource || resourceName == PersistentVolumeResource || resourceName == StorageClassResource ||
resourceName == NamespaceResource {
if resourceName == NodeResource || resourceName == PersistentVolumeResource || resourceName == StorageClassResource {
return false
}
return true
Expand Down

0 comments on commit 1df9175

Please sign in to comment.