From 2addf2cb73549b97d5724b299e0533e71e4fd98a Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Tue, 23 Jul 2024 17:41:01 +0200 Subject: [PATCH] use go-sysinfo v1.14.1 and elastic-agent-system-metrics v0.10.6 go-sysinfo was lower-casing FQDN by default, this new version does not. Not its user should do it if necessary. elastic-agent-system-metrics is also upgraded to a version that lowercase the FQDN when it's used as `host.name`. --- go.mod | 4 ++++ go.sum | 8 ++++---- internal/pkg/agent/application/info/agent_metadata.go | 9 ++++----- internal/pkg/composable/providers/host/host.go | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 42338b124b4..90f15ebdbd1 100644 --- a/go.mod +++ b/go.mod @@ -345,3 +345,7 @@ replace ( // Exclude this version because the version has an invalid checksum. exclude github.com/docker/distribution v2.8.0+incompatible + +replace github.com/elastic/go-sysinfo => github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c + +replace github.com/elastic/elastic-agent-system-metrics => github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20240723150030-6f29b3f88b68 diff --git a/go.sum b/go.sum index 986bb99f533..24797cc3463 100644 --- a/go.sum +++ b/go.sum @@ -598,6 +598,10 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= +github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20240723150030-6f29b3f88b68 h1:EA6fSGSg+eSOnDqpdIlooL5Qb6zS4v7Uemdl1lpgDi0= +github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20240723150030-6f29b3f88b68/go.mod h1:kstjNAFHhCHrW5MR+3xlVGfpWYtw3pXe5QzD4aolxcs= +github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c h1:JmYm9QiTPvea7Ya4NSVG0vUwZ9Q+qbfAW3mpkMgHB0E= +github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c/go.mod h1:FKUXnZWhnYI0ueO7jhsGV3uQJ5hiz8OqM5b3oGyaRr8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= @@ -748,8 +752,6 @@ github.com/elastic/elastic-agent-client/v7 v7.14.0 h1:X6S2RyjZNKsDCvA2igch2I5dgH github.com/elastic/elastic-agent-client/v7 v7.14.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI= github.com/elastic/elastic-agent-libs v0.9.15 h1:WCLtuErafUxczT/rXJa4Vr6mxwC8dgtqMbEq+qWGD4M= github.com/elastic/elastic-agent-libs v0.9.15/go.mod h1:2VgYxHaeM+cCDBjiS2wbmTvzPGbnlXAtYrlcLefheS8= -github.com/elastic/elastic-agent-system-metrics v0.10.4 h1:Tmb1rPRDyVv9M453YlPyl/gwUm9s4nSiI2xH76GGEz4= -github.com/elastic/elastic-agent-system-metrics v0.10.4/go.mod h1:cd7YgcTEjBNeLGnH/C9cEvP/YexohwS6CpmN9Ju58Mw= github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA= github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= github.com/elastic/go-docappender/v2 v2.2.0 h1:Pq6w+R0ZbWlqZHoqzoujR2ElKBfaPUf3M/cJvPVSrfA= @@ -762,8 +764,6 @@ github.com/elastic/go-licenser v0.4.2 h1:bPbGm8bUd8rxzSswFOqvQh1dAkKGkgAmrPxbUi+ github.com/elastic/go-licenser v0.4.2/go.mod h1:W8eH6FaZDR8fQGm+7FnVa7MxI1b/6dAqxz+zPB8nm5c= github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gnCJPDo1w= github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= -github.com/elastic/go-sysinfo v1.14.0 h1:dQRtiqLycoOOla7IflZg3aN213vqJmP0lpVpKQ9lUEY= -github.com/elastic/go-sysinfo v1.14.0/go.mod h1:FKUXnZWhnYI0ueO7jhsGV3uQJ5hiz8OqM5b3oGyaRr8= github.com/elastic/go-ucfg v0.8.8 h1:54KIF/2zFKfl0MzsSOCGOsZ3O2bnjFQJ0nDJcLhviyk= github.com/elastic/go-ucfg v0.8.8/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA= github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI= diff --git a/internal/pkg/agent/application/info/agent_metadata.go b/internal/pkg/agent/application/info/agent_metadata.go index 3a26944c446..d5223e75242 100644 --- a/internal/pkg/agent/application/info/agent_metadata.go +++ b/internal/pkg/agent/application/info/agent_metadata.go @@ -7,12 +7,11 @@ package info import ( "context" "fmt" - - "github.com/elastic/elastic-agent/pkg/features" - "runtime" "strings" + "github.com/elastic/elastic-agent/pkg/features" + "github.com/elastic/elastic-agent/internal/pkg/agent/application/paths" "github.com/elastic/elastic-agent/internal/pkg/agent/errors" "github.com/elastic/elastic-agent/internal/pkg/release" @@ -173,7 +172,7 @@ func (i *AgentInfo) ECSMetadata(l *logger.Logger) (*ECSMeta, error) { Host: &HostECSMeta{ Arch: info.Architecture, Hostname: hostname, - Name: hostname, + Name: strings.ToLower(hostname), ID: info.UniqueID, IP: info.IPs, MAC: info.MACs, @@ -211,7 +210,7 @@ func (i *AgentInfo) ECSMetadataFlatMap(l *logger.Logger) (map[string]interface{} // Host meta[hostArchKey] = info.Architecture meta[hostHostnameKey] = hostname - meta[hostNameKey] = hostname + meta[hostNameKey] = strings.ToLower(hostname) meta[hostIDKey] = info.UniqueID meta[hostIPKey] = fmt.Sprintf("[%s]", strings.Join(info.IPs, ",")) meta[hostMACKey] = fmt.Sprintf("[%s]", strings.Join(info.MACs, ",")) diff --git a/internal/pkg/composable/providers/host/host.go b/internal/pkg/composable/providers/host/host.go index afb48b32c05..eb344bc89cc 100644 --- a/internal/pkg/composable/providers/host/host.go +++ b/internal/pkg/composable/providers/host/host.go @@ -9,6 +9,7 @@ import ( "fmt" "reflect" "runtime" + "strings" "time" "github.com/elastic/elastic-agent/internal/pkg/agent/errors" @@ -141,7 +142,7 @@ func getHostInfo(log *logger.Logger) func() (map[string]interface{}, error) { return map[string]interface{}{ "id": info.UniqueID, - "name": name, + "name": strings.ToLower(name), "platform": runtime.GOOS, "architecture": info.Architecture, "ip": info.IPs,