> For the complete documentation index, see [llms.txt](https://docs.panther.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panther.com/ko/data-onboarding/data-pipeline-tools/fluentd/gcp-audit-to-s3-via-fluentd.md).

# Fluentd를 통한 GCP Audit에서 S3로의 전송

{% hint style="warning" %}
다음을 사용하는 것을 고려하세요 [Fluent Bit](/ko/data-onboarding/data-pipeline-tools/fluent-bit-onboarding-guide.md) Fluentd 대신 Panther로 로그를 전달하는 데 Fluent Bit를 사용하세요. Fluent Bit는 Fluentd보다 설정이 더 쉽고 리소스 사용량이 적습니다.
{% endhint %}

## 목표 <a href="#objectives" id="objectives"></a>

이 레시피의 목적은 Google Cloud 프로젝트 감사 로그를 Panther로 스트리밍하는 것입니다. 많은 기업이 여러 클라우드 제공업체를 사용하며, 이 단계들을 통해 GCP 계정에서 발생하는 API 호출을 Panther로 수집할 수 있습니다.

우리는 GCP와 AWS 전반의 기본 요소를 조합하여 이를 구현할 것입니다.

## 솔루션 개요 <a href="#solution-brief" id="solution-brief"></a>

전반적으로, 다음 흐름을 구현할 것입니다:

1. 감사 로그는 GCP에서 생성되어 PubSub로 라우팅됩니다
2. Fluentd가 PubSub를 폴링하고 S3 버킷으로 전달합니다
3. S3 버킷은 정규화, 디택션, 장기 저장을 위해 Panther에 온보딩됩니다

## 단계 <a href="#steps" id="steps"></a>

### 1단계: 새 Pub/Sub 만들기 <a href="#step-1-create-a-new-pub-sub" id="step-1-create-a-new-pub-sub"></a>

<figure><img src="/files/4ef22eeeca8d971b2e10ee92a5bdc10a211803dc" alt="The image shows the Pub/Sub console from Google Cloud Platform"><figcaption></figcaption></figure>

1. GCP에서 Pub/Sub 콘솔을 엽니다
2. 새 토픽을 만들고, 이름을 Panther-Audit로 지정합니다
   * ‘기본 구독 추가’의 선택을 해제합니다
   * CREATE TOPIC을 선택합니다
3. Subscriptions > Create subscription을 클릭합니다
   * Subscription ID로 Panther-Audit를 입력합니다
   * Panther-Audit 토픽을 선택합니다
   * 다른 모든 옵션은 그대로 두거나, 필요에 따라 만료/보존 기간을 조정합니다(의도한 지출/예산에 맞게)
   * CREATE를 클릭합니다

\
토픽 이름(projects/\<project-name>/topics/Panther-Audit)과 토픽 구독(Panther-Audit)을 메모해 둡니다. 나중에 사용합니다.

### 2단계: Logs Router 만들기 <a href="#step-2-create-a-logs-router" id="step-2-create-a-logs-router"></a>

<figure><img src="/files/f7123fddb024199f2f3960e21a537d475a48ad27" alt="The image shows the Logs Explorer page from Google Cloud Platform"><figcaption></figcaption></figure>

참고: 프로젝트 싱크 대신 집계된 조직 로그 싱크를 선택적으로 만들 수 있습니다. 집계된 싱크 생성에 대해 자세히 알아보려면 다음을 참조하세요. [Google 문서](https://cloud.google.com/logging/docs/export/aggregated_sinks#gcloud).

1. Logging 콘솔을 엽니다
2. Logs Router를 클릭합니다
3. CREATE SINK를 클릭합니다
4. 이름을 Panther-Audit로 설정합니다
5. Sink Destination을 설정합니다
   * Cloud Pub/Sub topic
   * Panther-Audit 토픽을 선택합니다
6. CREATE SINK를 클릭합니다

Pub/Sub로 이동하여 Panther-Audit의 Topic ID를 클릭한 다음, ACTIVITY를 확인해 감사 이벤트를 볼 수 있으면 이 파이프라인이 작동하는지 검증할 수 있습니다.

<figure><img src="/files/c5b66af1eadc39bc44fb71391818985850e153a9" alt="The image shows Google Cloud Platform&#x27;s Pub/Sub console. In the left sidebar, &#x22;Topics&#x22; is highlighted. The &#x22;Panther-audit&#x22; topic is selected."><figcaption></figcaption></figure>

### 3단계: 서비스 계정 만들기 <a href="#hardbreak-step-3-create-a-service-account" id="hardbreak-step-3-create-a-service-account"></a>

1. IAM & Admin을 엽니다
2. Service Accounts를 클릭합니다
3. CREATE SERVICE ACCOUNT를 클릭합니다
   * 서비스 계정 이름을 Panther-Audit로 설정합니다. 원하면 설명을 추가합니다.
   * Create and Continue를 클릭합니다
   * 아래의 **이 서비스 계정에 프로젝트 접근 권한을 부여합니다**에서 서비스 계정 액세스 역할을 *Pub/Sub Viewer* 및 *Pub/Sub Subscriber*
   * Continue를 클릭합니다
   * Done을 클릭합니다
4. Service accounts -> Actions에서 Manage keys, ADD KEY, Create new key를 클릭하고 JSON을 선택한 뒤 CREATE를 눌러 자격 증명을 다운로드합니다.
5. 이 자격 증명 파일은 안전하게 보관하세요! 곧 사용할 것입니다.

<figure><img src="/files/dc7244733971ce1cf3fa8fdeab6486c43fa0c14e" alt="The image shows the IAM &#x26; Admin console in Google Cloud Platform. In the left sidebar, &#x22;Service Accounts&#x22; is highlighted. The center of the page says &#x22;Service accounts for project &#x27;My First Project&#x27;&#x22;. In the list, the panther-audit project is selected. A 3-dots icon on the right is expanded to an open dropdown menu, and the option &#x22;Manage keys&#x22; is highlighted."><figcaption></figcaption></figure>

### 4단계: AWS 인프라 구성 <a href="#step-4-configure-aws-infrastructure" id="step-4-configure-aws-infrastructure"></a>

다음에서 [Fluentd 온보딩 가이드](/ko/data-onboarding/data-pipeline-tools/fluentd.md)를 검토하고 배포합니다 **Firehose 및 S3** 스택을.

### 5단계: AWS에서 인스턴스 시작 <a href="#step-5-launch-your-instance-in-aws" id="step-5-launch-your-instance-in-aws"></a>

1. AWS EC2 콘솔(위에서 스택을 시작한 것과 같은 리전에서)을 열고 Ubuntu 인스턴스를 시작합니다.
2. Launch Instance를 클릭합니다
   * 선택 **Ubuntu Server 20.04 LTS**
   * 선택 **t2.medium** (원하시면 더 강력한 인스턴스 유형도 가능합니다)
   * IAM Role 섹션에서 다음의 값을 선택합니다 **InstanceProfileName** 4단계에서 복사한 값으로, 형식은 “\<stack-name>-FirehoseInstanceProfile-\<random-string>”입니다.
   * Add Storage를 클릭하고 64GiB 용량 드라이브를 추가합니다
   * 원하는 대로 Security Group, Key Pair 및 기타 설정을 지정합니다
3. Launch를 클릭합니다

### 6단계: Fluentd 설치 및 구성 <a href="#step-6-install-and-configure-fluentd" id="step-6-install-and-configure-fluentd"></a>

1. 키페어를 ssh 에이전트에 추가합니다
   * `ssh-add <path-to-keypair>`
2. 3단계에서 다운로드한 GCP 자격 증명을 인스턴스로 SCP 전송합니다
   * `scp <path-to-gcp-cred-file> ubuntu@<public-ip>:/home/ubuntu/`
3. 새로 시작한 EC2 인스턴스에 SSH로 접속합니다
   * `ssh ubuntu@<public-ip>`
4. [Ubuntu용 Fluentd를 설치합니다](https://docs.fluentd.org/installation/install-by-deb)
   * Ubuntu Focal 지침을 따릅니다
5. 다음 [공식](https://github.com/awslabs/aws-fluent-plugin-kinesis) AWS Kinesis 플러그인
   * `sudo td-agent-gem install fluent-plugin-kinesis`
6. GCP 플러그인을 설치합니다
   * `sudo td-agent-gem install fluent-plugin-gcloud-pubsub-custom`
7. 기본 fluentd 구성을 다음에서 덮어씁니다 `/etc/td-agent/td-agent.conf`:

   ```
   <system>  
     log_level debug
   </system>

   <source>
     @type gcloud_pubsub
     tag gcp.audit
     project <YOUR-GCP-PROJECT-ID>
     key <PATH-TO-YOUR-KEYPAIR>
     topic <PANTHER-AUDIT-TOPIC-ID>
     subscription <PANTHER-AUDIT-SUBSCRIPTION-ID>
     max_messages 1000
     return_immediately true
     pull_interval 1
     pull_threads 2
     parse_error_action exception
     <parse>
       @type json
     </parse>
   </source>

   <match gcp.**>
     @type kinesis_firehose
     region <YOUR-FIREHOSE-REGION>
     delivery_stream_name <YOUR-FIREHOSE-NAME>

     <assume_role_credentials>
       duration_seconds 3600
       role_arn <YOUR-FIREHOSE-ROLE-ARN>
       role_session_name "#{Socket.gethostname}-panther-audit"
     </assume_role_credentials>
   </match>
   ```
8. 재시작 `td-agent`
   * `sudo systemctl restart td-agent`

### 7단계: Panther에 데이터 온보딩 <a href="#step-7-onboard-data-into-panther" id="step-7-onboard-data-into-panther"></a>

따라서 [GCP 감사 로그는](/ko/data-onboarding/supported-logs/gcp.md) 기본 제공으로 지원되므로, [S3 버킷을 데이터 전송 경로로 구성하여](/ko/data-onboarding/data-transports/aws/s3.md) Panther를 통해 로그 수집을 시작할 수 있습니다.

## **문제 해결**

* 참고: 다음 때문에 로그가 S3 버킷에 표시되기까지 약 5분이 걸릴 수 있습니다. `IntervalInSeconds`및 `SizeInMBs` CloudFormation 템플릿 내의 매개변수.
* 오류가 있는지 td-agent 로그를 모니터링합니다
  * `sudo tail -f /var/log/td-agent/td-agent.log`
* 더 자세한 로그가 필요하면 다음을 실행합니다:
  * `td-agent -vv`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.panther.com/ko/data-onboarding/data-pipeline-tools/fluentd/gcp-audit-to-s3-via-fluentd.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
