Skip to content

Commit

Permalink
Fix conversion of events with module fields (elastic#13544)
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 elastic#13433 with
other metricsets.

Fix elastic#13432

(cherry picked from commit b2ead08)
  • Loading branch information
jsoriano committed Sep 9, 2019
1 parent 5b046c5 commit 46ede79
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 @@ -99,7 +99,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix `logstash/node_stats` metricset to also collect `logstash_stats.events.duration_in_millis` field when `xpack.enabled: true` is set. {pull}13082[13082]
- Fix `logstash/node` metricset to also collect `logstash_state.pipeline.representation.{type,version,hash}` fields when `xpack.enabled: true` is set. {pull}13133[13133]
- Check if fields in DBInstance is nil in rds metricset. {pull}13294[13294] {issue}13037[13037]
- 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]

*Packetbeat*
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 46ede79

Please sign in to comment.