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

error logging improvements #373

Merged
merged 2 commits into from
Mar 8, 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
17 changes: 17 additions & 0 deletions agent/modules/stenoquery/stenoquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func (steno *StenoQuery) ProcessJob(job *model.Job, reader io.ReadCloser) (io.Re
"importId": job.Filter.ImportId,
}).Debug("Skipping steno processor due to presence of importId")
return reader, nil
} else if reader != nil {
log.WithFields(log.Fields{
"jobId": job.Id,
"kind": job.GetKind(),
}).Debug("Skipping steno processor due to another processor already provided PCAP data")
return reader, nil
} else if job.Filter == nil || job.Filter.EndTime.Before(steno.GetDataEpoch()) || job.Filter.BeginTime.After(steno.getDataLagDate()) {
log.WithFields(log.Fields{
"jobId": job.Id,
Expand Down Expand Up @@ -136,6 +142,17 @@ func (steno *StenoQuery) ProcessJob(job *model.Job, reader io.ReadCloser) (io.Re
var file *os.File
file, err = os.Open(pcapFilepath)
if err == nil {
info, err := os.Stat(pcapFilepath)
if err != nil {
log.WithError(err).WithFields(log.Fields {
"pcapPath": pcapFilepath,
}).Error("Failed to collect output file stats")
} else {
log.WithFields(log.Fields {
"pcapPath": pcapFilepath,
"pcapBytes": info.Size(),
}).Debug("Found matching packets")
}
reader = file
}
}
Expand Down
14 changes: 14 additions & 0 deletions agent/modules/suriquery/suriquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func (suri *SuriQuery) ProcessJob(job *model.Job, reader io.ReadCloser) (io.Read
"importId": job.Filter.ImportId,
}).Debug("Skipping suri processor due to presence of importId")
return reader, nil
} else if reader != nil {
log.WithFields(log.Fields{
"jobId": job.Id,
"kind": job.GetKind(),
}).Debug("Skipping suricata processor due to another processor already provided PCAP data")
return reader, nil
} else if job.Filter == nil || job.Filter.EndTime.Before(suri.GetDataEpoch()) || job.Filter.BeginTime.After(suri.getDataLagDate()) {
log.WithFields(log.Fields{
"jobId": job.Id,
Expand Down Expand Up @@ -179,6 +185,10 @@ func (suri *SuriQuery) streamPacketsInPcaps(paths []string, filter *model.Filter
log.WithError(perr).WithField("pcapPath", decompressedPath).Error("Failed to parse PCAP file")
}
if packets != nil && len(packets) > 0 {
log.WithFields(log.Fields {
"pcapPath": decompressedPath,
"packetCount": len(packets),
}).Debug("found matching packets")
allPackets = append(allPackets, packets...)
}

Expand Down Expand Up @@ -220,6 +230,10 @@ func (suri *SuriQuery) getPcapCreateTime(filepath string) (time.Time, error) {
func (suri *SuriQuery) findFilesInTimeRange(start time.Time, stop time.Time) []string {
eligibleFiles := make([]string, 0, 0)
err := filepath.Walk(suri.pcapInputPath, func(filepath string, fileinfo os.FileInfo, err error) error {
if err != nil {
return nil
}

if fileinfo.IsDir() {
return nil
}
Expand Down
Loading