Я хочу исключить некоторую строку в журналах, прочитанных filebeat, а также добавить тег с помощью процессоров в filebeat, но он не работает - PullRequest
0 голосов
/ 18 апреля 2019

Я хочу удалить строки журнала, содержащие слово «HealthChecker» в указанном журнале ниже, а также добавить некоторые теги в полезную нагрузку для отправки в logstash.

Мои журналы:

18.37.33.73 - - [18/Apr/2019:14:49:53 +0530] "GET /products?sort=date&direction=desc HTTP/1.1" 200 8543 "https://codingexplained.com/products/view/124" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A300 Safari/602.1"
20.4.2.88 - - [18/Apr/2019:14:49:54 +0530] "GET / HTTP/1.1" 200 100332 "-" "ELB-HealthChecker/2.0"
18.37.33.73 - - [18/Apr/2019:14:49:55 +0530] "GET /products?sort=date&direction=desc HTTP/1.1" 200 8543 "https://codingexplained.com/products/view/124" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A300 Safari/602.1"
20.4.2.88 - - [18/Apr/2019:14:49:56 +0530] "GET / HTTP/1.1" 200 100332 "-" "ELB-HealthChecker/2.0"

Я уже пытался указать эту конфигурацию внутри плагина процессора внутри файла filebeat.yml, но он все равно не работает.

Мой файл filebeat.yml:

filebeat.modules:
- module: apache
  access:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths: ["/location/apache_access_2017-09-28.log"]

    # Input configuration (advanced). Any input configuration option
    # can be added under this section.
    processors:
    - add_tags:
        tags: [web, production]
        target: "environment"
    - drop_event:
      when:
       contains:
         message: "ELB-HealthChecker"

filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

- type: log

  # Change to true to enable this input configuration.
  enabled: false

output.console:
  # Boolean flag to enable or disable the output module.
  enabled: true
  codec.json:
    pretty: true

1 Ответ

0 голосов
/ 18 апреля 2019

ЯМЛ виноват в вашем случае.«Процессор» - это элемент верхнего уровня, поэтому он будет работать:

filebeat.modules:
- module: apache
  access:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths: ["/location/apache_access_2017-09-28.log"]

    # Input configuration (advanced). Any input configuration option
    # can be added under this section.

processors:
- add_tags:
    tags: [web, production]
    target: "environment"
- drop_event:
  when:
   contains:
     message: "ELB-HealthChecker"

Если у вас есть сомнения относительно отступа, обратитесь к файлу filebeat.full.yml.

...