Skip to content

Commit

Permalink
Use DefaultMetaGeneratorConfig in MetadataEnrichers to initialize con…
Browse files Browse the repository at this point in the history
…figurations (elastic#13414)
  • Loading branch information
ChrsMark authored Aug 30, 2019
1 parent ba71859 commit cf48299
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add rate metrics for ec2 metricset. {pull}13203[13203]
- Add Performance metricset to Oracle module {pull}12547[12547]
- Add proc/vmstat data to the system/memory metricset on linux {pull}13322[13322]
- Use DefaultMetaGeneratorConfig in MetadataEnrichers to initialize configurations {pull}13414 [13414]

*Packetbeat*

Expand Down
17 changes: 11 additions & 6 deletions libbeat/common/kubernetes/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,27 @@ type MetaGeneratorConfig struct {
ExcludeLabels []string `config:"exclude_labels"`
IncludeAnnotations []string `config:"include_annotations"`

LabelsDedot bool `config:"labels.dedot"`
AnnotationsDedot bool `config:"annotations.dedot"`

// Undocumented settings, to be deprecated in favor of `drop_fields` processor:
IncludeCreatorMetadata bool `config:"include_creator_metadata"`
LabelsDedot bool `config:"labels.dedot"`
AnnotationsDedot bool `config:"annotations.dedot"`
}

type metaGenerator = MetaGeneratorConfig

// NewMetaGenerator initializes and returns a new kubernetes metadata generator
func NewMetaGenerator(cfg *common.Config) (MetaGenerator, error) {
// default settings:
generator := metaGenerator{
// DefaultMetaGeneratorConfig initializes and returns a new MetaGeneratorConfig with default values
func DefaultMetaGeneratorConfig() MetaGeneratorConfig {
return MetaGeneratorConfig{
IncludeCreatorMetadata: true,
LabelsDedot: true,
AnnotationsDedot: true,
}
}

// NewMetaGenerator initializes and returns a new kubernetes metadata generator
func NewMetaGenerator(cfg *common.Config) (MetaGenerator, error) {
generator := DefaultMetaGeneratorConfig()

err := cfg.Unpack(&generator)
return &generator, err
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/kubernetes/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func NewResourceMetadataEnricher(
return &nilEnricher{}
}

metaConfig := kubernetes.MetaGeneratorConfig{}
metaConfig := kubernetes.DefaultMetaGeneratorConfig()
if err := base.Module().UnpackConfig(&metaConfig); err != nil {
logp.Err("Error initializing Kubernetes metadata enricher: %s", err)
return &nilEnricher{}
Expand Down Expand Up @@ -186,7 +186,7 @@ func NewContainerMetadataEnricher(
return &nilEnricher{}
}

metaConfig := kubernetes.MetaGeneratorConfig{}
metaConfig := kubernetes.DefaultMetaGeneratorConfig()
if err := base.Module().UnpackConfig(&metaConfig); err != nil {
logp.Err("Error initializing Kubernetes metadata enricher: %s", err)
return &nilEnricher{}
Expand Down

0 comments on commit cf48299

Please sign in to comment.