-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add replace_fields config option in add_host_metadata for replacing host fields #20490
Conversation
Pinging @elastic/integrations-platforms (Team:Platforms) |
@jsoriano I consider this is a breaking change. Is it ok to add this in next release? |
@kaiyan-sheng I agree that this is a breaking change, but it seems needed for the inventory efforts, and I think that for the cases we will be breaking it will be more a fix than a breaking change 🙂 Apart of "breaking" the case of Something else we can do to mitigate possible problems is to add a We can also add, in the note you are adding in |
Hmm not what I can think of. I will post it here if I see any other case.
Good point! I added My thought is, we can keep it default as true right now to match the previous/original behavior and then switch the default to false in 8.0.
Done. Thank you! |
Ok, let's avoid making it a breaking change by now, we can still reconsider this before 7.10. I was convinced that it was better to make the breaking change, and I still think it would be for Metricbeat now that we are adding more logic in modules for the host inventory. But then I have thought on Filebeat and I am not so sure. There are probably SIEM use cases where log parsing is adding host information, but additional network information is still wanted. And also, we are adding this processor by default in the Kubernetes manifests for Filebeat. Btw (naming is complicated), I find having |
Done.
Done, yeah I was thinking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, added some nitpicking comments.
We can decide to make it a breaking change later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generator errors in CI have been fixed in master by #20586. The other errors are flaky ones.
Merging this PR. If we decide to change |
return false | ||
} | ||
|
||
hostFieldsMap := hostFields.(common.MapStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will panic if the host
is not a common.MapStr
. Since Beats like Filebeat can handle arbitrary data it should be defensive (for example see
Lines 207 to 216 in 95626b8
func tryToMapStr(v interface{}) (common.MapStr, bool) { | |
switch m := v.(type) { | |
case common.MapStr: | |
return m, true | |
case map[string]interface{}: | |
return common.MapStr(m), true | |
default: | |
return nil, false | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andrewkroh for pointing this out! I will create a separate PR to fix this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the PR: #20791
…ost fields (elastic#20490) * add replace_host_fields config param
What does this PR do?
This PR adds
replace_fields
config option inadd_host_metadata
for replacing host fields. By default,replace_fields
equals totrue
to make sure this PR is not a breaking change.Why is it important?
We are adding common host fields into several modules in Metricbeat, such as
host.id
andhost.name
. Butadd_host_metadata
processor would overwritehost.id
field without this PR.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
This PR should work for any module/metricset. I'm using aws module as an example here:
aws
module by./metricbeat modules enable aws
aws
configmodules.d/aws.yml
to:metricbeat.yml
,add_host_metadata
processor is enabled andreplace_fields
is set tofalse
:./metricbeat -e
host.*
fields only fromec2
metricset but not any fields fromadd_host_metadata
such ashost.hostname
,host.architecture
,host.os.*
etc.Related issues
#20464