Skip to content

Commit

Permalink
Add debug logging statements to auditbeat system/socket metricset (el…
Browse files Browse the repository at this point in the history
…astic#41571)

* add a few log statements

* add debug log statements to system/socket

* add changelog
  • Loading branch information
fearful-symmetry authored Nov 21, 2024
1 parent 4dd3bfd commit d31f1e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]

*Auditbeat*

- Improve logging in system/socket {pull}41571[41571]


*Auditbeat*


Expand Down
10 changes: 10 additions & 0 deletions x-pack/auditbeat/module/system/socket/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ func (s *state) ForkProcess(parentPID, childPID uint32, ts kernelTime) error {
for k, v := range parent.resolvedDomains {
child.resolvedDomains[k] = v
}
s.log.Debugf("forking process %d with %d associated domains", childPID, len(child.resolvedDomains))
s.processes[childPID] = child
}
return nil
Expand All @@ -579,6 +580,7 @@ func (s *state) TerminateProcess(pid uint32) error {
if pid == 0 {
return errors.New("can't terminate process with PID 0")
}
s.log.Debugf("terminating process %d", pid)
s.Lock()
defer s.Unlock()
delete(s.processes, pid)
Expand Down Expand Up @@ -676,6 +678,7 @@ func (s *state) CreateSocket(ref flow) error {
func (s *state) OnDNSTransaction(tr dns.Transaction) error {
s.Lock()
defer s.Unlock()
s.log.Debugf("adding DNS transaction for domain %s for client %s", tr.Domain, tr.Client.String())
s.dns.AddTransaction(tr)
return nil
}
Expand Down Expand Up @@ -721,6 +724,10 @@ func (s *state) mutualEnrich(sock *socket, f *flow) {
}

func (s *state) createFlow(ref flow) error {
if ref.process != nil {
s.log.Debugf("creating flow for pid %s", ref.process.pid)
}

// Get or create a socket for this flow
sock := s.getSocket(ref.sock)
ref.createdTime = ref.lastSeenTime
Expand Down Expand Up @@ -821,6 +828,9 @@ func (s *state) enrichDNS(f *flow) {
IP: f.local.addr.IP,
Port: f.local.addr.Port,
}
if f.process != nil {
s.log.Debugf("registering endpoint %s for process %d", localUDP.String(), f.process.pid)
}
s.dns.RegisterEndpoint(localUDP, f.process)
}
}
Expand Down

0 comments on commit d31f1e6

Please sign in to comment.