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

[Heartbeat] Remove host.name field from events #14140

Merged
merged 4 commits into from
Oct 22, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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{
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't remember anymore the full affect of this. Does it only remove the host.* name fields or any other fields too?

Copy link
Member

Choose a reason for hiding this comment

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

This should just remove the default host.name field. In comparison to this line, which I think the default for a beat, the difference is just the lack of WithHost.

return MakeDefaultSupport(normalize, WithECS, WithHost, WithBeatMeta("agent"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's my understanding as well

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