본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

필터를 프로세서로 사용하기

원문 보기 위키 갱신

Fluent Bit에서는 어떤 필터든 프로세서로 사용할 수 있어요. 프로세서는 YAML 설정 파일에서만 지원돼요.

출처: 문서

본문

Fluent Bit에서는 어떤 필터든 프로세서로 사용할 수 있어요.

{% hint style="info" %} 프로세서는 YAML 설정 파일에서만 지원돼요. {% endhint %}

예제

다음 예제들은 필터를 프로세서로 구성하는 방법을 보여줘요.

Grep

이 예제에서는 Grep 필터가 정규식 패턴을 기반으로 로그 이벤트를 필터링하는 입력 프로세서로 사용돼요.

{% tabs %} {% tab title="fluent-bit.yaml" %}

parsers:
    - name: json
      format: json

pipeline:
    inputs:
        - name: tail
          path: /var/log/example.log
          parser: json

          processors:
              logs:
                  - name: grep
                    regex: log aa
    outputs:
        - name: stdout
          match: '*'

{% endtab %} {% endtabs %}

Lua

이 예제 설정에서는 입력 플러그인이 Lua 필터를 프로세서로 사용해 hostname이라는 새 키에 monox 값을 추가해요. 그런 다음 출력 플러그인이 output이라는 새 키에 new data 값을 추가해요.

{% tabs %} {% tab title="fluent-bit.yaml" %}

  service:
    log_level: info
    http_server: on
    http_listen: 0.0.0.0
    http_port: 2021
  pipeline:
    inputs:
      - name: random
        tag: test-tag
        interval_sec: 1
        processors:
          logs:
            - name: modify
              add: hostname monox
            - name: lua
              call: append_tag
              code: |
                  function append_tag(tag, timestamp, record)
                     new_record = record
                     new_record["tag"] = tag
                     return 1, timestamp, new_record
                  end
    outputs:
      - name: stdout
        match: '*'
        processors:
          logs:
            - name: lua
              call: add_field
              code: |
                  function add_field(tag, timestamp, record)
                     new_record = record
                     new_record["output"] = "new data"
                     return 1, timestamp, new_record
                  end

{% endtab %} {% endtabs %}

더 알아보기 (Learn more)