# Fluent Bit 구성 예시

이 페이지의 예시는 Fluent Bit로 데이터를 수신하고 로그를 Panther로 전송하는 일반적인 방법을 제공합니다. 이는 다음을 통해 가능합니다. [HTTP 소스](/ko/data-onboarding/data-transports/http.md) 또는 다음을 통해 [Amazon S3 소스](/ko/data-onboarding/data-transports/aws/s3.md).

{% hint style="warning" %}
아래 예시에서는 `log_level trace` 및 출력 `stdout` 은 구성 테스트 및 디버깅에 사용됩니다. Fluent Bit 구성이 예상대로 작동하면 이 설정들은 제거해야 합니다.
{% endhint %}

## Panther HTTP 소스로의 Dummy

이 예시는 [Fluent Bit의 Dummy 입력](https://docs.fluentbit.io/manual/pipeline/inputs/dummy) 을 사용하여 초당 하나의 이벤트를 생성합니다. 이는 출력 구성을 테스트하고 Fluent Bit를 시작하는 데 유용합니다.

입력: [Dummy](https://docs.fluentbit.io/manual/pipeline/inputs/dummy)

출력: [HTTP](https://docs.fluentbit.io/manual/pipeline/inputs/http)

```yaml
[SERVICE]
    log_level trace

[INPUT]
    이름 dummy
    Dummy {"message": "sample json message", "type": "json"}

[OUTPUT]
    이름       http
    Match      *
    Host       logs.{REDACTED}.runpanther.net
    Port       443
    URI        /http/{REDACTED}
    Header     x-sender-header {REDACTED}
    Format     json_lines
    TLS        On
    TLS.Verify On
    Json_Date_Key false

[OUTPUT]
    이름   stdout
    Match  *
```

이 구성을 적용하면 다음과 같은 결과가 나옵니다:

```
# 입력 구성:
Dummy {"message": "sample json message", "type": "json"}
    
# Panther 파싱 전 원시 이벤트의 출력:
{"message": "sample json message", "type": "json"}
```

## 로컬 파일을 따라 Amazon S3로 전송

이 예시는 Tail 입력을 사용하여 로컬에서 S3로 전송된 파일을 수집합니다. 여러 파일을 제공할 수 있습니다. 자세한 내용은 다음을 참조하세요. `path` 설정은 다음의 [Fluent Bit Tail 문서](https://docs.fluentbit.io/manual/pipeline/inputs/tail) 를 참조하세요.

입력: [Tail](https://docs.fluentbit.io/manual/pipeline/inputs/tail)

출력: [S3](https://docs.fluentbit.io/manual/pipeline/outputs/s3)

{% hint style="info" %}
OUTPUT 플러그인 구성에서:

* 다음을 사용하여`json_date_key false` 추가된 날짜 키를 비활성화합니다.
* 다음을 사용하여 `log_key log` 를 사용하여 Fluent Bit가 원시 로그만 전송하도록 지정합니다.

이 두 설정을 사용하면 로그 파일의 원시 입력이 Fluent Bit가 추가한 JSON 필드 없이 전송됩니다.
{% endhint %}

```yaml
[SERVICE]
    log_level trace

[INPUT]
    이름       tail
    태그        wifi_log
    경로       /var/log/wifi.log

[OUTPUT]
    이름       s3
    Match      *
    리전     {REGION}
    버킷     {BUCKET_NAME}
    압축 gzip
    json_date_key false
    upload_timeout 5m
    log_key log

    # AWS 자격 증명 가져오기 - https://github.com/fluent/fluent-bit-docs/blob/43c4fe134611da471e706b0edb2f9acd7cdfdbc3/administration/aws-credentials.md

[OUTPUT]
    이름   stdout
    Match  *
```

이 구성을 적용하면 다음과 같은 결과가 나옵니다:

```
# 파일을 tailing하여 얻은 입력 결과:
Mon Feb  5 16:17:04.165 Usb Host Notification hostNotificationUSBDeviceInserted USB Billboard Device    isApple N seqNum 454 Total 4
Mon Feb  5 16:17:04.176 Usb Host Notification Apple80211Set: seqNum 454 Total 4 chg 1 en0
Mon Feb  5 16:17:28.841 Usb Host Notification hostNotificationUSBDeviceInserted USB MICROPHONE isApple N seqNum 455 Total 5
Mon Feb  5 16:17:28.846 Usb Host Notification Apple80211Set: seqNum 455 Total 5 chg 1 en0
    
# AWS S3의 출력 결과:
Mon Feb  5 16:17:04.165 Usb Host Notification hostNotificationUSBDeviceInserted USB Billboard Device    isApple N seqNum 454 Total 4
Mon Feb  5 16:17:04.176 Usb Host Notification Apple80211Set: seqNum 454 Total 4 chg 1 en0
Mon Feb  5 16:17:28.841 Usb Host Notification hostNotificationUSBDeviceInserted USB MICROPHONE isApple N seqNum 455 Total 5
Mon Feb  5 16:17:28.846 Usb Host Notification Apple80211Set: seqNum 455 Total 5 chg 1 en0
```

## Amazon S3로의 TCP

이 예시는 TCP 입력 플러그인을 사용합니다. 이 플러그인은 네트워크를 통해 syslog 또는 JSON 이벤트를 Fluent Bit로 전송해야 할 때 유용합니다. TCP 플러그인은 수신한 원시 페이로드를 가져와 출력 구성으로 전달합니다.

입력: [TCP](https://docs.fluentbit.io/manual/pipeline/inputs/tcp)

출력: [S3](https://docs.fluentbit.io/manual/pipeline/outputs/s3)

```yaml
[SERVICE]
    log_level trace

[INPUT]
    이름       tcp
    태그        tcp_log
    Listen     0.0.0.0
    Port       5140
    Format     none

[OUTPUT]
    이름       s3
    Match      *
    리전     {REGION}
    버킷     {BUCKET_NAME}
    압축 gzip
    json_date_key false
    upload_timeout 5m
    log_key log

    # AWS 자격 증명 가져오기 - https://github.com/fluent/fluent-bit-docs/blob/43c4fe134611da471e706b0edb2f9acd7cdfdbc3/administration/aws-credentials.md

[OUTPUT]
    이름   stdout
    Match  *
```

이 구성을 적용하면 다음과 같은 결과가 나옵니다:

```
# 입력 명령:
%echo "message from local echo" | nc 127.0.0.1 5140
%echo "message from local echo" | nc 127.0.0.1 5140

# 접두사 tcp_log/2024/02/06/02/55/generated_filename가 있는 AWS S3의 출력:
message from local echo
message from local echo
```

## HTTP(Panther)로의 TCP

이 예시 구성은 TCP 입력 플러그인을 사용하여 로그를 수신하고 Panther의 [HTTP 수집](/ko/data-onboarding/data-transports/http.md) 으로 Fluent Bit의 HTTP 출력 플러그인을 사용해 직접 전송하는 방법을 보여줍니다.

입력: [TCP](https://docs.fluentbit.io/manual/pipeline/inputs/tcp)

출력: [HTTP](https://docs.fluentbit.io/manual/pipeline/outputs/http)

{% hint style="info" %}
아래 구성에서 필터를 사용하는 것은 로그를 HTTP 대상으로 보낼 때 원시 페이로드를 그대로 유지하기 위해 필요합니다. 다음을 참조하세요. [Fluent Bit HTTP 출력 문서](https://docs.fluentbit.io/manual/pipeline/outputs/http) 를 참조하세요.
{% endhint %}

```yaml
[SERVICE]
    log_level trace

[INPUT]
    이름       tcp
    태그        tcp_log
    Listen     0.0.0.0
    Port       5140
    Format     none

# https://stackoverflow.com/questions/75291515/how-to-disable-json-format-and-send-only-the-log-message-to-sumologic-with-fluen
[FILTER]
    이름 record_modifier
    Match *
    Record headers.content-type text/plain

# https://stackoverflow.com/questions/75291515/how-to-disable-json-format-and-send-only-the-log-message-to-sumologic-with-fluen
[FILTER]
    이름 nest
    Match *
    Operation nest
    Wildcard headers.*
    Nest_under headers
    Remove_prefix headers.


[OUTPUT]
    이름       http
    Match      *
    Host       logs.{REDACTED}.runpanther.net
    Port       443
    URI        /http/{REDACTED}
    Header     x-sender-header {REDACTED}
    Format     json_lines
    TLS        On
    TLS.Verify On
    Json_Date_Key false
    body_key   $log
    headers_key $headers

[OUTPUT]
    이름   stdout
    Match  *
```

이 구성을 적용하면 다음과 같은 결과가 나옵니다:

```
# 입력 명령: 
% echo "message from local echo `date`" | nc 127.0.0.1 5140
% echo "message from local echo `date`" | nc 127.0.0.1 5140
% echo "message from local echo `date`" | nc 127.0.0.1 5140

# Panther 파싱 전 원시 이벤트의 출력:
message from local echo Mon Feb 5 19:27:40 PST 2024
message from local echo Mon Feb 5 19:27:52 PST 2024
message from local echo Mon Feb 5 19:27:53 PST 2024
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.panther.com/ko/data-onboarding/data-pipeline-tools/fluent-bit-onboarding-guide/fluent-bit-configuration-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
