I am trying to add two dynamic fields in Filebeats by calling the command via Python. The fields themselves are populated after some processing is done so I cannot pre-populate it in a .yml
file. Otherwise I know I can have the following code in my .yml
file:
.
.
processors:
- add_fields:
fields:
field1: "str1"
field2: "str2"
.
.
Since I cannot change field1 or field2 to the actual values with this file. I have built a command that looks like:
filebeat -c /etc/filebeat/config.yml --once --path.data=UUID -E "processors=[{{add_fields: {{fields: [ field1:['foo'], field2:['bar']]}}]"
When I run this command I get the following error:
Error: invalid argument "processors=[{add_fields: {fields: [ field1:['foo'], field2:['bar']]}]" for "-E, --E" flag: dictionary expected ',' or '}' when parsing '[{add_fields: {fields: [ field1:['foo'], field2:['bar']]}]'
How can I dynamically add fields to Filebeat?