grok_pattern.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package types
  2. import (
  3. "github.com/antonmedv/expr/vm"
  4. "github.com/crowdsecurity/grokky"
  5. )
  6. //Used mostly for statics
  7. type ExtraField struct {
  8. //if the target is indicated by name Struct.Field etc,
  9. TargetByName string `yaml:"target,omitempty"`
  10. //if the target field is in Event map
  11. Parsed string `yaml:"parsed,omitempty"`
  12. //if the target field is in Meta map
  13. Meta string `yaml:"meta,omitempty"`
  14. //if the target field is in Enriched map
  15. Enriched string `yaml:"enriched,omitempty"`
  16. //the source is a static value
  17. Value string `yaml:"value,omitempty"`
  18. //or the result of an Expression
  19. ExpValue string `yaml:"expression,omitempty"`
  20. RunTimeValue *vm.Program `json:"-"` //the actual compiled filter
  21. //or an enrichment method
  22. Method string `yaml:"method,omitempty"`
  23. }
  24. type GrokPattern struct {
  25. //the field to which regexp is going to apply
  26. TargetField string `yaml:"apply_on,omitempty"`
  27. //the grok/regexp by name (loaded from patterns/*)
  28. RegexpName string `yaml:"name,omitempty"`
  29. //a proper grok pattern
  30. RegexpValue string `yaml:"pattern,omitempty"`
  31. //the runtime form of regexpname / regexpvalue
  32. RunTimeRegexp *grokky.Pattern `json:"-"` //the actual regexp
  33. //the output of the expression is going to be the source for regexp
  34. ExpValue string `yaml:"expression,omitempty"`
  35. RunTimeValue *vm.Program `json:"-"` //the actual compiled filter
  36. //a grok can contain statics that apply if pattern is successful
  37. Statics []ExtraField `yaml:"statics,omitempty"`
  38. }