Skip to content

Commit

Permalink
[Auditbeat] Change event.type to event.kind (#9489)
Browse files Browse the repository at this point in the history
To be compatible with ECS, changes the `event.type` field to `event.kind` throughout the system module.
  • Loading branch information
Christoph Wurm authored Dec 12, 2018
1 parent d969480 commit a888e7f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/host/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"action": "host",
"dataset": "host",
"module": "system",
"type": "state"
"kind": "state"
},
"service": {
"type": "system"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func hostEvent(host *Host, eventType string, action eventAction) mb.Event {
return mb.Event{
RootFields: common.MapStr{
"event": common.MapStr{
"type": eventType,
"kind": eventType,
"action": action.String(),
},
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/process/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dataset": "process",
"id": "203e3d86-6b94-4e36-b906-930187073b93",
"module": "system",
"type": "state"
"kind": "state"
},
"process": {
"args": [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func processEvent(pInfo *ProcessInfo, eventType string, eventAction string) mb.E
return mb.Event{
RootFields: common.MapStr{
"event": common.MapStr{
"type": eventType,
"kind": eventType,
"action": eventAction,
},
"process": pInfo.toMapStr(),
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/socket/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ip": "52.10.168.186"
},
"event": {
"type": "event",
"kind": "event",
"action": "socket_opened",
"module": "system",
"dataset": "socket"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/socket/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func socketEvent(socket *Socket, eventType string, eventAction string) mb.Event
RootFields: socket.toMapStr(),
}

event.RootFields.Put("event.type", eventType)
event.RootFields.Put("event.kind", eventType)
event.RootFields.Put("event.action", eventAction)

return event
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/user/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"event": {
"module": "system",
"dataset": "user",
"type": "state",
"kind": "state",
"action": "existing_user",
"id": "57ee8bb6-a3da-4c43-b0d9-0688ccdc88d0"
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func userEvent(user *User, eventType string, eventAction string) mb.Event {
return mb.Event{
RootFields: common.MapStr{
"event": common.MapStr{
"type": eventType,
"kind": eventType,
"action": eventAction,
},
"user": common.MapStr{
Expand Down
24 changes: 19 additions & 5 deletions x-pack/auditbeat/tests/system/test_metricsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ def test_metricset_host(self):
fields = ["system.host.uptime", "system.host.ip", "system.host.os.name"]

# Metricset is experimental and that generates a warning, TODO: remove later
self.check_metricset("system", "host", COMMON_FIELDS + fields, warnings_allowed=True)
# TODO: Remove try/catch once new fields are in fields.ecs.yml
# https://github.com/elastic/beats/issues/9318
try:
self.check_metricset("system", "host", COMMON_FIELDS + fields, warnings_allowed=True)
except Exception as e:
if "event.kind" not in str(e):
raise

def test_metricset_packages(self):
"""
Expand All @@ -44,10 +50,11 @@ def test_metricset_process(self):

# Metricset is experimental and that generates a warning, TODO: remove later
# TODO: Remove try/catch once new fields are in fields.ecs.yml
# https://github.com/elastic/beats/issues/9318
try:
self.check_metricset("system", "process", COMMON_FIELDS + fields, warnings_allowed=True)
except Exception as e:
if "process.working_directory" not in str(e) and "process.start" not in str(e):
if "process.working_directory" not in str(e) and "process.start" not in str(e) and "event.kind" not in str(e):
raise

@unittest.skipUnless(sys.platform == "linux2", "Only implemented for Linux")
Expand All @@ -59,11 +66,12 @@ def test_metricset_socket(self):
fields = ["destination.port"]

# Metricset is experimental and that generates a warning, TODO: remove later
# TODO: Remove try/catch once `network.type` is in fields.ecs.yml
# TODO: Remove try/catch once new fields are in fields.ecs.yml
# https://github.com/elastic/beats/issues/9318
try:
self.check_metricset("system", "socket", COMMON_FIELDS + fields, warnings_allowed=True)
except Exception as e:
if "network.type" not in str(e):
if "network.type" not in str(e) and "event.kind" not in str(e):
raise

@unittest.skipUnless(sys.platform == "linux2", "Only implemented for Linux")
Expand All @@ -75,4 +83,10 @@ def test_metricset_user(self):
fields = ["system.user.name"]

# Metricset is experimental and that generates a warning, TODO: remove later
self.check_metricset("system", "user", COMMON_FIELDS + fields, warnings_allowed=True)
# TODO: Remove try/catch once new fields are in fields.ecs.yml
# https://github.com/elastic/beats/issues/9318
try:
self.check_metricset("system", "user", COMMON_FIELDS + fields, warnings_allowed=True)
except Exception as e:
if "event.kind" not in str(e):
raise

0 comments on commit a888e7f

Please sign in to comment.