Cann't use custom fields as a condition to drop fields


(Wang Yaohua) #1

This is my config

filebeat.prospectors:
- input_type: log
  paths:
    - /var/log/xaa
  fields:
    Host: ${HOSTNAME}
  fields_under_root: true
  document_type: nginx
  tags: test
  exclude_lines: ['GET / HTTP/1.1"']
processors:
- drop_fields.when:
    - contains:
      - Host: 'vm1'
        - fields:
          - "beat"
          - "offset"

I use filebeat -c /etc/filebeat/filebeat.yml -path.logs /var/log/filebeat/ -path.data /var/lib/filebeat/ -configtest
The filebeat output

filebeat2017/07/24 10:12:14.974970 beat.go:339: CRIT Exiting: error loading config file: yaml: line 25: did not find expected key
Exiting: error loading config file: yaml: line 25: did not find expected key


(Tudor Golubenco) #2

Try this:

processors:
- drop_fields:
    fields: ["beat", "offset"]
    when.contains.host: "vm1"

I didn't test, but that's how I would write it.


(Wang Yaohua) #3

it's work.thanks.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.