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

Add debug logging statements to auditbeat system/socket metricset #41571

Merged
merged 4 commits into from
Nov 21, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,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
Loading