Skip to content

Commit

Permalink
comply with ECS for host.name and host.hostname (#168)
Browse files Browse the repository at this point in the history
Upgrades go-sysinfo to v1.14.1, which does not lower-case the FQDN. As a result, `host.name` returned by `host.MapHostInfo` is now lower-cased to comply with [ECS](https://www.elastic.co/guide/en/ecs/current/ecs-host.html#field-host-name).

This change ensures the FQDN is not lower-cased by default and that `host.hostname`, when set to FQDN, reflects the FQDN as defined in the system.
  • Loading branch information
AndersonQ authored Jul 26, 2024
1 parent 50700ed commit e8645b5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
40 changes: 35 additions & 5 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v

--------------------------------------------------------------------------------
Dependency : github.com/elastic/go-sysinfo
Version: v1.14.0
Version: v1.14.1
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].0/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].1/LICENSE.txt:


Apache License
Expand Down Expand Up @@ -1480,12 +1480,12 @@ limitations under the License.


--------------------------------------------------------------------------------
Dependency : github.com/gofrs/uuid
Version: v4.4.0+incompatible
Dependency : github.com/gofrs/uuid/v5
Version: v5.2.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/[email protected]/LICENSE:

Copyright (C) 2013-2018 by Maxim Bublis <[email protected]>

Expand Down Expand Up @@ -3243,6 +3243,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/gofrs/uuid
Version: v4.4.0+incompatible
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/gofrs/[email protected]+incompatible/LICENSE:

Copyright (C) 2013-2018 by Maxim Bublis <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/gogo/protobuf
Version: v1.3.2
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/elastic/elastic-agent-libs v0.9.13
github.com/elastic/go-licenser v0.4.2
github.com/elastic/go-structform v0.0.9
github.com/elastic/go-sysinfo v1.14.0
github.com/elastic/go-sysinfo v1.14.1
github.com/elastic/go-windows v1.0.1
github.com/elastic/gosigar v0.14.2
github.com/gofrs/uuid/v5 v5.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ 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.9 h1:HpcS7xljL4kSyUfDJ8cXTJC6rU5ChL1wYb6cx3HLD+o=
github.com/elastic/go-structform v0.0.9/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-sysinfo v1.14.1 h1:BpY/Utfz75oKSpsQnbAJmmlnT3gBV9WFsopBEYgjhZY=
github.com/elastic/go-sysinfo v1.14.1/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.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
Expand Down
4 changes: 3 additions & 1 deletion metric/system/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package host

import (
"strings"

"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/elastic/elastic-agent-libs/monitoring"
"github.com/elastic/go-sysinfo"
Expand All @@ -33,7 +35,7 @@ func MapHostInfo(info types.HostInfo, fqdn string) mapstr.M {

data := mapstr.M{
"host": mapstr.M{
"name": name,
"name": strings.ToLower(name),
"hostname": info.Hostname,
"architecture": info.Architecture,
"os": mapstr.M{
Expand Down
6 changes: 3 additions & 3 deletions metric/system/host/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestMapHostInfo(t *testing.T) {
Architecture: "x86_64",
BootTime: bootTime,
Containerized: &containerized,
Hostname: "foo",
Hostname: "fOo",
IPs: []string{"1.2.3.4", "192.168.1.1"},
KernelVersion: "22.3.0",
MACs: []string{"56:9c:17:54:19:15", "5c:e9:1e:c4:37:66"},
Expand All @@ -66,7 +66,7 @@ func TestMapHostInfo(t *testing.T) {
"host": mapstr.M{
"architecture": "x86_64",
"containerized": true,
"hostname": "foo",
"hostname": "fOo",
"id": "a39b4c1ee4",
"name": "foo.bar.local",
"os": mapstr.M{
Expand All @@ -87,7 +87,7 @@ func TestMapHostInfo(t *testing.T) {
"host": mapstr.M{
"architecture": "x86_64",
"containerized": true,
"hostname": "foo",
"hostname": "fOo",
"id": "a39b4c1ee4",
"name": "foo",
"os": mapstr.M{
Expand Down

0 comments on commit e8645b5

Please sign in to comment.