-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autodiscover appenders should concatenate processor arrays #11184
Comments
Thank you for your feedback. I think this request makes sense, while I have some doubts on how we can implement this in a way that the result is what most users expect. As of today appenders override existing configs. As a workaround for your specific case, this could work: Move your
This way the appender is not clashing with any existing processor but you still get renaming |
Thanks, I'll try that the next time I have a chance. As for possible implementations, I did a brief check of the code and noticed in the underlying go-ucfg library, there is a way to specify how configs should be merged (replace, append, or prepend): https://github.com/elastic/go-ucfg/blob/1273e33847d004780f826af2de52e327c0322f5c/opts.go#L141-L154 I wonder if it would be reasonable to allow specifying the merge method in the appenders config, and have the default be what it is currently (replace). As a possible example: appenders:
- type: config
condition.equals.kubernetes.labels.k8s-app: filebeat
+ merge: append
config:
processors:
- decode_json_fields:
fields: ["message"]
target: ""
overwrite_keys: true
- drop_fields:
fields: ["timestamp"] this way, users know exactly what to expect. It's just a thought though, as I don't know much about the underlying implementation. |
I think this should be fixed by #16450, which will be released in 7.7. Please reopen if you still see the issue |
(Text below copied from forum thread)
I'm trying to use autodiscover, where I have some processors defined in the
templates
config, as well as some processors defined in theappenders
section under certain conditions, like so:What I would expect to happen is for the two
processors
arrays to be concatenated.However, I keep getting the error "Error creating runner from config: each processor needs to have exactly one action, but found 2 actions" which confused me, because the processors looked correct to me.
I think I was able to figure out the issue though, it's that when filebeat attempts to combine the
appenders
config with thetemplates
config, it may be flattening the array representations and combining each of the individual items with the same array index.i.e., I imagine it was attempting to combine my
rename
processor with mydecode_json_fields
processor into one object, like:which is very much an invalid processor.
I was able to work around it by changing my
appenders
definition to use numbered syntax for arrays, with numbers that don't overlap with the ones defined above:Now clearly this isn't an optimal solution, as I would expect the appender to just concatenate the arrays. Has anyone else encountered this issue? I'm encountering it on 7.0.0-beta1 but I imagine it's present in 6.x as well.
Here's a specific location in the code where this can be tested: https://github.com/elastic/beats/blob/7.x/libbeat/autodiscover/appenders/config/config_test.go
I was able to confirm it locally by adding a test that had an array field containing objects in both the
eventConfig
andconfig
fields, and was seeing that the objects at each array index were being merged.The text was updated successfully, but these errors were encountered: