Skip to content

Commit

Permalink
feat(inputs.suricata): Add ability to parse drop or rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj committed Apr 6, 2023
1 parent 35edd18 commit a675373
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plugins/inputs/suricata/suricata.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,23 @@ func (s *Suricata) parse(acc telegraf.Accumulator, sjson []byte) error {
if err != nil {
return err
}
// check for presence of relevant stats or alert
// check for presence of relevant stats or alert or drop or reject
_, ok := result["stats"]
_, ok2 := result["alert"]
if !ok && !ok2 {
s.Log.Debugf("Invalid input without 'stats' or 'alert' object: %v", result)
return fmt.Errorf("input does not contain 'stats' or 'alert' object")
_, ok3 := result["drop"]
_, ok4 := result["reject"]
if !ok && !ok2 && !ok3 && !ok4 {
s.Log.Debugf("Invalid input without 'stats' or 'alert' or 'drop' or 'reject' object: %v", result)
return fmt.Errorf("input does not contain 'stats' or 'alert' or 'drop' or 'reject' object")
}
if ok {
s.parseStats(acc, result)
} else if ok2 && s.Alerts {
s.parseAlert(acc, result)
} else if ok3 && s.Alerts {
s.parseAlert(acc, result)
} else if ok4 && s.Alerts {
s.parseAlert(acc, result)
}
return nil
}
Expand Down

0 comments on commit a675373

Please sign in to comment.