Skip to content

Commit

Permalink
[Heartbeat] Remove host.name field from events (elastic#14140)
Browse files Browse the repository at this point in the history
This field should never have been present, and is a distraction from the
observer.* fields.

Resolves elastic#12107
  • Loading branch information
andrewvc authored and jorgemarey committed Dec 13, 2019
1 parent 2db9b29 commit f1f423b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Heartbeat*

- Removed the `add_host_metadata` and `add_cloud_metadata` processors from the default config. These don't fit well with ECS for Heartbeat and were rarely used.
- Removed `host.name` field that should never have been included. Heartbeat uses `observer.*` fields instead. {pull}14140[14140]

*Journalbeat*

Expand Down
10 changes: 8 additions & 2 deletions heartbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package cmd

import (
"fmt"
// register default heartbeat monitors

_ "github.com/elastic/beats/heartbeat/autodiscover"
"github.com/elastic/beats/heartbeat/beater"
// register default heartbeat monitors
_ "github.com/elastic/beats/heartbeat/monitors/defaults"
cmd "github.com/elastic/beats/libbeat/cmd"
"github.com/elastic/beats/libbeat/cmd/instance"
"github.com/elastic/beats/libbeat/publisher/processing"
)

// Name of this beat
Expand All @@ -34,7 +36,11 @@ var Name = "heartbeat"
var RootCmd *cmd.BeatsRootCmd

func init() {
RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name})
settings := instance.Settings{
Name: Name,
Processing: processing.MakeDefaultSupport(true, processing.WithECS, processing.WithBeatMeta("agent")),
}
RootCmd = cmd.GenRootCmdWithSettings(beater.New, settings)

// remove dashboard from export commands
for _, cmd := range RootCmd.ExportCmd.Commands() {
Expand Down
24 changes: 24 additions & 0 deletions heartbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ def test_fields_not_under_root(self):
}
)

def test_host_fields_not_present(self):
"""
Ensure that libbeat isn't adding any host.* fields
"""
monitor = {
"type": "http",
"urls": ["http://localhost:9200"],
}
config = {
"monitors": [monitor]
}

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/*",
**config
)

heartbeat_proc = self.start_beat()
self.wait_until(lambda: self.output_lines() > 0)
heartbeat_proc.check_kill_and_wait()
doc = self.read_output()[0]

assert not doc.has_key("host.name")

def run_fields(self, expected, local=None, top=None):
monitor = {
"type": "http",
Expand Down

0 comments on commit f1f423b

Please sign in to comment.