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

[Enhanncement for host.ip and host.mac] Disabling netinfo.enabled option of add-host-metadata processor #36506

Merged
merged 15 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
*Affecting all Beats*
- Fix status reporting to Elastic-Agent when output configuration is invalid running under Elastic-Agent {pull}35719[35719]
- Upgrade Go to 1.20.7 {pull}36241[36241]
- [Enhanncement for host.ip and host.mac] Disabling netinfo.enabled option of add-host-metadata processor {pull}36506[36506]
Setting environmental variable ELASTIC_NETINFO:false in Elastic Agent pod will disable the netinfo.enabled option of add_host_metadata processor

*Auditbeat*

Expand Down
25 changes: 20 additions & 5 deletions libbeat/processors/add_host_metadata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package add_host_metadata

import (
"os"
"time"

"github.com/elastic/beats/v7/libbeat/processors/util"
Expand All @@ -34,10 +35,24 @@ type Config struct {
}

func defaultConfig() Config {
return Config{
NetInfoEnabled: true,
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
// Setting environmental variable ELASTIC_NETINFO:false in Elastic Agent pod will disable the netinfo.enabled option of add_host_metadata processor
// This will result to events not being enhanced with host.ip and host.mac
// Related to https://github.com/elastic/integrations/issues/6674
valueNETINFO, _ := os.LookupEnv("ELASTIC_NETINFO")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure we have this documented. Can you expand the changelog to contain a mention of this env variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this is ok, I added some info also there.

Also see elastic/ingest-docs#463


if valueNETINFO == "false" {
return Config{
NetInfoEnabled: false,
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
}
} else {
return Config{
NetInfoEnabled: true,
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
}
Comment on lines +43 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion to increase readability

Suggested change
if valueNETINFO == "false" {
return Config{
NetInfoEnabled: false,
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
}
} else {
return Config{
NetInfoEnabled: true,
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
}
return Config{
NetInfoEnabled: valueNETINFO == "true",
CacheTTL: 5 * time.Minute,
ExpireUpdateTimeout: time.Second * 10,
ReplaceFields: true,
}

}
}
Loading