Skip to content

Commit

Permalink
Add related.user and related.ip
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Stucki committed May 5, 2020
1 parent ef57caf commit 2135405
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x-pack/auditbeat/module/system/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (ms *MetricSet) loginEvent(loginRecord *LoginRecord) mb.Event {

if loginRecord.Username != "" {
event.RootFields.Put("user.name", loginRecord.Username)

event.RootFields.Put("related.user", []string{loginRecord.Username})
if loginRecord.UID != -1 {
event.RootFields.Put("user.id", loginRecord.UID)
}
Expand All @@ -194,6 +194,7 @@ func (ms *MetricSet) loginEvent(loginRecord *LoginRecord) mb.Event {

if loginRecord.IP != nil {
event.RootFields.Put("source.ip", loginRecord.IP)
event.RootFields.Put("related.ip", []string{loginRecord.IP.String()})
}

if loginRecord.Hostname != "" && loginRecord.Hostname != loginRecord.IP.String() {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/auditbeat/module/system/login/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func TestWtmp(t *testing.T) {
checkFieldValue(t, events[0].RootFields, "event.action", "user_logout")
checkFieldValue(t, events[0].RootFields, "process.pid", 14962)
checkFieldValue(t, events[0].RootFields, "source.ip", "10.0.2.2")
checkFieldValue(t, events[0].RootFields, "related.ip", []string{"10.0.2.2"})
checkFieldValue(t, events[0].RootFields, "user.name", "vagrant")
checkFieldValue(t, events[0].RootFields, "related.user", []string{"vagrant"})
checkFieldValue(t, events[0].RootFields, "user.terminal", "pts/2")
}

Expand Down

0 comments on commit 2135405

Please sign in to comment.