Skip to content

Commit

Permalink
revert changes related to the 'commonMetaConfig'; add missing metadat…
Browse files Browse the repository at this point in the history
…a configuration on the metricset level

Signed-off-by: Tetiana Kravchenko <[email protected]>
  • Loading branch information
tetianakravchenko committed Dec 22, 2023
1 parent eff4a88 commit 0215971
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 20 deletions.
23 changes: 19 additions & 4 deletions metricbeat/docs/modules/kubernetes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,18 @@ metricbeat.modules:
# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true
# When used outside the cluster:
#node: node_name
# 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.
# add_resource_metadata:
Expand Down Expand Up @@ -276,13 +283,21 @@ metricbeat.modules:
# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true
# When used outside the cluster:
#node: node_name
# Set the namespace to watch for resources
#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.
# add_resource_metadata:
Expand Down
23 changes: 19 additions & 4 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,18 @@ metricbeat.modules:

# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name

# 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.
# add_resource_metadata:
Expand Down Expand Up @@ -548,13 +555,21 @@ metricbeat.modules:

# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name

# Set the namespace to watch for resources
#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.
# add_resource_metadata:
Expand Down
23 changes: 19 additions & 4 deletions metricbeat/module/kubernetes/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@

# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name

# 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.
# add_resource_metadata:
Expand Down Expand Up @@ -62,13 +69,21 @@

# Enriching parameters:
add_metadata: true
# When used outside the cluster:
#node: node_name
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name

# Set the namespace to watch for resources
#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.
# add_resource_metadata:
Expand Down
12 changes: 9 additions & 3 deletions metricbeat/module/kubernetes/_meta/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@

# Enriching parameters:
#add_metadata: true
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name
# 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 resources
#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.
# add_resource_metadata:
Expand Down
17 changes: 15 additions & 2 deletions metricbeat/module/kubernetes/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ func NewResourceMetadataEnricher(
return &nilEnricher{}
}

cfg, _ := conf.NewConfigFrom(&config)
// commonMetaConfig stores the metadata configuration of the resource itself
commonMetaConfig := metadata.Config{}
if err := base.Module().UnpackConfig(&commonMetaConfig); err != nil {
logp.Err("Error initializing Kubernetes metadata enricher: %s", err)
return &nilEnricher{}
}
cfg, _ := conf.NewConfigFrom(&commonMetaConfig)

// if Resource is Pod then we need to create watchers for Replicasets and Jobs that it might belongs to
// in order to be able to retrieve 2nd layer Owner metadata like in case of:
Expand Down Expand Up @@ -302,7 +308,14 @@ func NewContainerMetadataEnricher(
return &nilEnricher{}
}

cfg, _ := conf.NewConfigFrom(&config)
// commonMetaConfig stores the metadata configuration of the resource itself
commonMetaConfig := metadata.Config{}
if err := base.Module().UnpackConfig(&commonMetaConfig); err != nil {
logp.Err("Error initializing Kubernetes metadata enricher: %s", err)
return &nilEnricher{}
}
cfg, _ := conf.NewConfigFrom(&commonMetaConfig)

// Resource is Pod so we need to create watchers for Replicasets and Jobs that it might belongs to
// in order to be able to retrieve 2nd layer Owner metadata like in case of:
// Deployment -> Replicaset -> Pod
Expand Down
12 changes: 9 additions & 3 deletions metricbeat/modules.d/kubernetes.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@

# Enriching parameters:
#add_metadata: true
# 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
#include_labels: []
#exclude_labels: []
#include_annotations: []
#labels.dedot: true
#annotations.dedot: true

# When used outside the cluster:
#node: node_name
# 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 resources
#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.
# add_resource_metadata:
Expand Down

0 comments on commit 0215971

Please sign in to comment.