# Fluentd를 통한 Windows 이벤트 로그 -> S3 (레거시)

{% hint style="danger" %}
이 가이드에 설명된 프로세스는 더 이상 Windows Event Logs 온보딩에 권장되는 방법이 아닙니다. 대신, Fluent Bit를 활용하는 [Windows Event Logs](/ko/data-onboarding/supported-logs/windows-event-logs.md)의 지침을 따르세요. Fluent Bit 설정 프로세스는 Fluentd보다 덜 복잡하며 추가 인프라도 필요하지 않습니다.
{% endhint %}

## 개요

이 가이드는 Fluentd를 사용하여 Windows Event Logs를 S3로 전달하는 방법을 제공합니다. 두 가지 파이프라인 흐름이 있습니다. AWS Firehose 전송 스트림을 통해 전달하거나 AWS S3 버킷으로 직접 전달하는 방식입니다.

### 사전 요구 사항

이 가이드는 S3 버킷 또는 Firehose가 이미 생성되어 있다고 가정합니다. 이러한 리소스 중 하나를 생성해야 한다면 다음을 참고하세요. [Fluentd 온보딩 가이드](/ko/data-onboarding/data-pipeline-tools/fluentd.md). 이미 리소스를 프로비저닝했다면 아래 가이드를 필요에 맞게 조정할 수 있습니다.

## Fluentd 설정

### 1단계. Fluentd 설치

Fluentd 설치 [지침을](https://docs.fluentd.org/installation/install-by-msi) 따라 Windows Event Logs를 수집하려는 Windows 서버에 설치하세요. Fluentd가 서비스로 실행되고 있는지 확인하려면 설치 지침을 참조하세요.

### 2단계. Fluentd 구성 편집

아래 구성으로 Fluentd 구성을 편집하세요. 이렇게 하면 Fluentd가 `windows_eventlog2` 플러그인을 사용하여 이벤트를 읽고 S3로 출력하도록 구성됩니다. 아래 구성에서 다음 항목을 업데이트하세요. `s3_bucket`, `s3_region`, `aws_key_id`, 및 `aws_sec_key` 을(를) 다음 구성에서 수정하세요:

```
C:\opt\td-agent\etc\td-agent\td-agent.conf
```

```
<source>
  @type windows_eventlog2
  @id windows_eventlog2
  channels application,system,security
  tag system
  render_as_xml true
  <storage>
    persistent false
  </storage>
  parse_description false
  read_existing_events false
</source>

<match system.**>	
  @type s3

  s3_bucket <BUCKET-NAME>
  s3_region <BUCKET-REGION>
  path winevent/%Y/%m/%d/
  store_as gzip	

  ## 아래에는 두 가지 인증 방법이 있습니다. 
  ## EC2에서 실행 중인 경우, 토큰 키 대신 assume role 자격 증명을 사용할 수 있습니다.

  ## 시크릿 토큰 인증
  #aws_key_id <ACCESS-KEY-ID>
  #aws_sec_key <SECRET-KEY>

  ## Assume Role 인증
  <assume_role_credentials>
    duration_seconds 3600
    role_arn <ROLE-ARN>
    role_session_name "#{Socket.gethostname}-panther-audit"
  </assume_role_credentials>

  <buffer tag,time>
    @type file
    path /var/log/fluent/s3
    timekey 300 # 5분 파티션
    timekey_wait 2m
    timekey_use_utc true # UTC 사용
    chunk_limit_size 256m
  </buffer>
  <format>
    @type json
  </format>
</match>

#<match system.**>
#  @type kinesis_firehose
#  region <STREAM-REGION>
#  delivery_stream_name <FIREHOSE-STREAM-NAME>
#
#  <assume_role_credentials>
#    duration_seconds 3600
#    role_arn <ROLE-ARN>
#    role_session_name "#{Socket.gethostname}-panther-audit"
#  </assume_role_credentials>
#  <format>
#    @type json
#  </format>
#</match>
```

다음에서 `windows_eventlog2` 플러그인 [에 대해 더 자세히 읽어볼 수 있습니다](https://github.com/fluent/fluent-plugin-windows-eventlog#in_windows_eventlog2).

### 3단계. Fluentd 시작

명령 프롬프트에서 아래 명령으로 서비스를 시작하거나 다시 시작하세요. 이전에 실행 중이었다면 서비스를 중지한 후 다시 시작해야 할 수도 있습니다.

```
sc stop fluentdwinsvc
sc start fluentdwinsvc
```

다음 명령으로 서비스가 실행 중인지 확인하세요:

```
sc query fluentdwinsvc
```

서비스가 실행 중일 때의 예상 출력:

```
C:\Users\Administrator>sc query fluentdwinsvc

SERVICE_NAME: fluentdwinsvc
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
```

다음 위치에서 Fluentd 런타임 로그를 확인할 수 있습니다. `C:\opt\td-agent\td-agent.log`

문제를 해결하려면 명령줄에서 td-agent를 실행하고 다음을 통해 실시간 출력을 검토할 수도 있습니다. `C:\opt\td-agent\bin\td-agent -vv`. 수동으로 실행하기 전에 Fluentd 서비스를 중지하세요.

### 4단계. 로깅 확인

몇 분 후 이벤트가 S3 버킷에 기록되는지 확인하세요. 로그는 버킷 내 `winevent/` 접두사 아래에 표시되어야 합니다.

## Panther 콘솔

### 1단계. 사용자 지정 스키마 생성

다음으로 이동하세요 **Configure > Schemas**. 클릭하세요 **+New Schema** 그런 다음 스키마 필드에 아래 값을 입력하세요:

**이름:** Custom.WindowsEventLogs2\
**설명:** 애플리케이션, 보안, 시스템용 Windows 이벤트 로그

```yaml
#fluentd의 windows_eventlog2 타입을 위한 스키마
version: 0
fields:
- name: TimeCreated
  required: true
  type: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
- name: ActivityID
  required: true
  type: string
- name: Channel
  required: true
  type: string
- name: Computer
  required: true
  type: string
- name: Description
  required: true
  type: string
- name: EventData
  required: true
  type: array
  element:
    type: string
- name: EventID
  required: true
  type: bigint
- name: EventRecordID
  required: true
  type: bigint
- name: Keywords
  required: true
  type: string
- name: Level
  required: true
  type: bigint
- name: Opcode
  required: true
  type: string
- name: ProcessID
  required: true
  type: string
- name: ProviderGUID
  required: true
  type: string
- name: ProviderName
  required: true
  type: string
- name: Qualifiers
  required: true
  type: string
- name: RelatedActivityID
  required: true
  type: string
- name: Task
  required: true
  type: bigint
- name: ThreadID
  required: true
  type: string
- name: UserID
  required: true
  type: string
- name: Version
  required: true
  type: string
```

위 스키마는 이 가이드 앞부분에서 제공한 Fluentd 소스 지시문 구성의 로그를 사용하여 생성되었습니다.

### 2단계. S3 버킷 온보딩 <a href="#step-2.-onboard-the-s3-bucket" id="step-2.-onboard-the-s3-bucket"></a>

다음을 따르세요 [S3 소스](/ko/data-onboarding/data-transports/aws/s3.md) 온보딩 문서를 참고하고 이전 설정에서 사용한 S3 버킷을 사용하세요.

로그 유형을 선택하고 `Custom.WindowsEventLogs2` 온보딩 단계에서 접두사를 `winevent/` 지정하세요. 버킷 온보딩을 완료하면 데이터가 이제 Panther로 유입되기 시작해야 합니다!


---

# 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/fluentd/windows-event-logging-via-fluentd.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.
