diff --git a/config/processors.go b/config/processors.go index 00895427..980af7b5 100644 --- a/config/processors.go +++ b/config/processors.go @@ -39,7 +39,7 @@ func (c *Config) GetEventProcessors() (map[string]map[string]interface{}, error) c.Processors[n] = es } for n := range c.Processors { - expandMapEnv(c.Processors[n]) + expandMapEnv(c.Processors[n], "expression", "condition") } if c.Debug { c.logger.Printf("processors: %+v", c.Processors) diff --git a/formatters/event_jq/event_jq_test.go b/formatters/event_jq/event_jq_test.go index 3d801ad6..e370eb57 100644 --- a/formatters/event_jq/event_jq_test.go +++ b/formatters/event_jq/event_jq_test.go @@ -698,6 +698,47 @@ var testset = map[string]struct { }, }, }, + "expression_with_$var": { + processorType: processorType, + processor: map[string]interface{}{ + "condition": `.values | has("a")`, + "expression": `.[] | .values.a as $x | .values.b=$x+1`, + "debug": true, + }, + tests: []item{ + { + input: nil, + output: nil, + }, + { + input: make([]*formatters.EventMsg, 0), + output: make([]*formatters.EventMsg, 0), + }, + { + input: []*formatters.EventMsg{ + { + Name: "sub1", + Values: map[string]interface{}{ + "a": 42, + }, + Tags: map[string]string{"tag1": "1"}, + }, + }, + output: []*formatters.EventMsg{ + { + Name: "sub1", + Values: map[string]interface{}{ + "a": 42, + "b": 43, + }, + Tags: map[string]string{ + "tag1": "1", + }, + }, + }, + }, + }, + }, } func TestEventJQ(t *testing.T) {