allow user to specify stash's cache strategy (#2037)

This commit is contained in:
Thibault "bui" Koechlin 2023-02-06 15:42:55 +01:00 committed by GitHub
parent 987f119c4b
commit a0b264047c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -121,6 +121,9 @@ func (n *Node) validate(pctx *UnixParserCtx, ectx EnricherCtx) error {
if stash.TTL == "" {
return fmt.Errorf("stash %s : ttl must be set", stash.Name)
}
if stash.Strategy == "" {
stash.Strategy = "LRU"
}
//should be configurable
if stash.MaxMapSize == 0 {
stash.MaxMapSize = 100
@ -573,6 +576,7 @@ func (n *Node) compile(pctx *UnixParserCtx, ectx EnricherCtx) error {
Size: n.Stash[i].MaxMapSize,
TTL: n.Stash[i].TTLVal,
Name: n.Stash[i].Name,
Strategy: n.Stash[i].Strategy,
LogLevel: &logLvl,
}); err != nil {
return errors.Wrap(err, "while initializing cache")

View file

@ -51,4 +51,5 @@ type DataCapture struct {
TTL string `yaml:"ttl,omitempty"`
TTLVal time.Duration `yaml:"-"`
MaxMapSize int `yaml:"size,omitempty"`
Strategy string `yaml:"strategy,omitempty"`
}