瀏覽代碼

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

Thibault "bui" Koechlin 2 年之前
父節點
當前提交
a0b264047c
共有 2 個文件被更改,包括 5 次插入0 次删除
  1. 4 0
      pkg/parser/node.go
  2. 1 0
      pkg/types/grok_pattern.go

+ 4 - 0
pkg/parser/node.go

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

+ 1 - 0
pkg/types/grok_pattern.go

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