Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change add_cloud_metadata to not overwrite cloud field #11612

Merged
merged 9 commits into from
Apr 9, 2019
Prev Previous commit
Next Next commit
Only check cloudValue for overwriting
kaiyan-sheng committed Apr 9, 2019
commit faabe4a93071ea838e17aa1229a6dc4258adb78c
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add _bucket to histogram metrics in Prometheus Collector {pull}11578[11578]
- Prevent the docker/memory metricset from processing invalid events before container start {pull}11676[11676]
- Stop overwriting cloud.* fields from add_cloud_metadata if they are not empty. {pull}11612[11612] {issue}11305[11305]
- Change `add_cloud_metadata` processor to not overwrite `cloud` field when it's already exist in the event. {pull}11612[11612] {issue}11305[11305]

*Packetbeat*

8 changes: 4 additions & 4 deletions libbeat/processors/add_cloud_metadata/add_cloud_metadata.go
Original file line number Diff line number Diff line change
@@ -361,12 +361,12 @@ func (p *addCloudMetadata) Run(event *beat.Event) (*beat.Event, error) {
// If cloud key exists in event already, this processor will not overwrite the cloud fields.
// For example aws module writes cloud.instance.* to events already, add_cloud_metadata should not overwrite these
// fields again.
cloudValue, err := event.GetValue("cloud")
if cloudValue != nil && err == nil {
return event, err
cloudValue, _ := event.GetValue("cloud")
if cloudValue != nil {
return event, nil
}

_, err = event.PutValue("cloud", meta)
_, err := event.PutValue("cloud", meta)

return event, err
}