Skip to content

Commit

Permalink
Add event.dataset field (elastic#9408)
Browse files Browse the repository at this point in the history
This brings us closer to ECS compliance by adding the event.dataset field.

All heartbeat events are considered part of the 'uptime' dataset, even though their data may differ.

The key thing defining this dataset is the presence of the `monitor.status` field

(cherry picked from commit 5e54acb)
andrewvc committed Dec 14, 2018
1 parent 6f8366d commit c035df6
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions heartbeat/monitors/task.go
Original file line number Diff line number Diff line change
@@ -123,9 +123,11 @@ func (t *task) makeSchedulerTaskFunc() scheduler.TaskFunc {
// Start schedules this task for execution.
func (t *task) Start() {
var err error

t.client, err = t.monitor.pipelineConnector.ConnectWith(beat.ClientConfig{
EventMetadata: t.config.EventMetadata,
Processor: t.processors,
Fields: common.MapStr{"event": common.MapStr{"dataset": "uptime"}},
})
if err != nil {
logp.Err("could not start monitor: %v", err)
31 changes: 31 additions & 0 deletions heartbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
from heartbeat import BaseTest
from elasticsearch import Elasticsearch
from beat.beat import INTEGRATION_TESTS
import nose.tools


class Test(BaseTest):
@@ -130,3 +131,33 @@ def test_template(self):
assert exit_code == 0
assert self.log_contains('Loaded index template')
assert len(es.cat.templates(name='heartbeat-*', h='name')) > 0

def test_dataset(self):
"""
Test that event.dataset is set to `uptime`
"""
self.render_config_template(
monitors=[
{
"type": "http",
"urls": ["http://localhost:9200"]
},
{
"type": "tcp",
"hosts": ["localhost:9200"]
}
]
)

try:
heartbeat_proc = self.start_beat()
self.wait_until(lambda: self.output_lines() >= 2)
finally:
heartbeat_proc.check_kill_and_wait()

for output in self.read_output():
nose.tools.assert_equal(
output["event.dataset"],
"uptime",
"Check for event.dataset in {} failed".format(output)
)

0 comments on commit c035df6

Please sign in to comment.