Skip to content

Commit

Permalink
Fix conversion of events with module fields (#13544) (#13552)
Browse files Browse the repository at this point in the history
Use `TransformMapStrToEvent` also to convert events in the
kubernetes `state_node` metricset, as was done in #13433 with
other metricsets.

Fix #13432

(cherry picked from commit b2ead08)
  • Loading branch information
jsoriano committed Sep 9, 2019
1 parent b8a44b3 commit e0bb1c1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Check if fields in DBInstance is nil in rds metricset. {pull}13294[13294] {issue}13037[13037]
- Fix silent failures in kafka and prometheus module. {pull}13353[13353] {issue}13252[13252]
- Fix issue with aws cloudwatch module where dimensions and/or namespaces that contain space are not being parsed correctly {pull}13389[13389]
- Fix module-level fields in Kubernetes metricsets. {pull}13433[13433]
- Fix module-level fields in Kubernetes metricsets. {pull}13433[13433] {pull}13544[13544]
- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426]
- Fix reporting empty events in cloudwatch metricset. {pull}13458[13458]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
[
{
"RootFields": null,
"RootFields": {},
"ModuleFields": null,
"MetricSetFields": {
"cpu": {
"allocatable": {
"cores": 3
"cores": 2
},
"capacity": {
"cores": 4
"cores": 2
}
},
"memory": {
"allocatable": {
"bytes": 3097786880
"bytes": 2097786880
},
"capacity": {
"bytes": 4097786880
"bytes": 2097786880
}
},
"name": "minikube-test",
"name": "minikube",
"pod": {
"allocatable": {
"total": 210
"total": 110
},
"capacity": {
"total": 310
"total": 110
}
},
"status": {
"ready": "true",
"unschedulable": true
"unschedulable": false
}
},
"Index": "",
Expand All @@ -40,40 +40,42 @@
"Error": null,
"Host": "",
"Service": "",
"Took": 0
"Took": 0,
"Period": 0,
"DisableTimeSeries": false
},
{
"RootFields": null,
"RootFields": {},
"ModuleFields": null,
"MetricSetFields": {
"cpu": {
"allocatable": {
"cores": 2
"cores": 3
},
"capacity": {
"cores": 2
"cores": 4
}
},
"memory": {
"allocatable": {
"bytes": 2097786880
"bytes": 3097786880
},
"capacity": {
"bytes": 2097786880
"bytes": 4097786880
}
},
"name": "minikube",
"name": "minikube-test",
"pod": {
"allocatable": {
"total": 110
"total": 210
},
"capacity": {
"total": 110
"total": 310
}
},
"status": {
"ready": "true",
"unschedulable": false
"unschedulable": true
}
},
"Index": "",
Expand All @@ -83,6 +85,8 @@
"Error": null,
"Host": "",
"Service": "",
"Took": 0
"Took": 0,
"Period": 0,
"DisableTimeSeries": false
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"RootFields": null,
"RootFields": {},
"ModuleFields": null,
"MetricSetFields": {
"cpu": {
Expand Down Expand Up @@ -40,6 +40,8 @@
"Error": null,
"Host": "",
"Service": "",
"Took": 0
"Took": 0,
"Period": 0,
"DisableTimeSeries": false
}
]
10 changes: 6 additions & 4 deletions metricbeat/module/kubernetes/state_node/state_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {

m.enricher.Enrich(events)
for _, event := range events {
reporter.Event(mb.Event{
MetricSetFields: event,
Namespace: "kubernetes.node",
})
event[mb.NamespaceKey] = "node"
reported := reporter.Event(mb.TransformMapStrToEvent("kubernetes", event, nil))
if !reported {
m.Logger().Debug("error trying to emit event")
return
}
}
}

Expand Down

0 comments on commit e0bb1c1

Please sign in to comment.