Skip to content

Commit

Permalink
volume metricset: replace adding ECS orchestrator fields with util.Ad…
Browse files Browse the repository at this point in the history
…dClusterECSMeta

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
  • Loading branch information
tetianakravchenko committed Sep 7, 2022
1 parent 375a08f commit afa7fc6
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions metricbeat/module/kubernetes/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/elastic/beats/v7/metricbeat/mb/parse"
k8smod "github.com/elastic/beats/v7/metricbeat/module/kubernetes"
"github.com/elastic/beats/v7/metricbeat/module/kubernetes/util"
"github.com/elastic/elastic-agent-autodiscover/kubernetes"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"
)
Expand Down Expand Up @@ -82,26 +80,9 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
BaseMetricSet: base,
http: http,
mod: mod,
clusterMeta: util.AddClusterECSMeta(base),
}

// add ECS orchestrator fields
config, err := util.GetValidatedConfig(base)
if err != nil {
logp.Info("Kubernetes metricset enriching is disabled")
} else {
client, err := kubernetes.GetKubernetesClient(config.KubeConfig, config.KubeClientOptions)
if err != nil {
return nil, fmt.Errorf("fail to get kubernetes client: %w", err)
}
cfg, _ := conf.NewConfigFrom(&config)
ecsClusterMeta, err := util.GetClusterECSMeta(cfg, client, ms.Logger())
if err != nil {
ms.Logger().Debugf("could not retrieve cluster metadata: %w", err)
}
if ecsClusterMeta != nil {
ms.clusterMeta = ecsClusterMeta
}
}
return ms, nil
}

Expand Down

0 comments on commit afa7fc6

Please sign in to comment.