Skip to content

Commit

Permalink
Check existance of rootfields
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKatsoulis committed Feb 4, 2022
1 parent 4ca4e6c commit 0a0a543
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions metricbeat/module/kubernetes/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
// Enrich event with container ECS fields
containerEcsFields := ecsfields(event)
if len(containerEcsFields) != 0 {
e.RootFields = common.MapStr{
"container": containerEcsFields,
if e.RootFields != nil {
e.RootFields.DeepUpdate(common.MapStr{
"container": containerEcsFields,
})
} else {
e.RootFields = common.MapStr{
"container": containerEcsFields,
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions metricbeat/module/kubernetes/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,16 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
// Enrich event with container ECS fields
containerEcsFields := ecsfields(event)
if len(containerEcsFields) != 0 {
e.RootFields = common.MapStr{
"container": containerEcsFields,
if len(containerEcsFields) != 0 {
if e.RootFields != nil {
e.RootFields.DeepUpdate(common.MapStr{
"container": containerEcsFields,
})
} else {
e.RootFields = common.MapStr{
"container": containerEcsFields,
}
}
}
}

Expand Down

0 comments on commit 0a0a543

Please # to comment.