Skip to content

Commit

Permalink
[Enhanncement for host.ip and host.mac] Disabling netinfo.enabled opt…
Browse files Browse the repository at this point in the history
…ion of add-host-metadata processor (#36506)

* adding check for host processor in case of K8s

* Changing variable to ELASTIC_NETINFO

* Updating changelog for variable  ELASTIC_NETINFO
  • Loading branch information
gizas authored Sep 8, 2023
1 parent 8d3aa91 commit 0f47b30
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
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")

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,
}
}
}

0 comments on commit 0f47b30

Please sign in to comment.