# Envoy 로그

## 개요

Panther는 다음을 수집하는 것을 지원합니다 [Envoy 액세스](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage) 이를 스트리밍하여 로그 [HTTP 소스](https://docs.panther.com/ko/data-onboarding/data-transports/http)로 전달된 후에, [Fluent Bit.](https://docs.fluentbit.io/manual/)

## Envoy 로그를 Panther에 온보딩하는 방법

### 1단계: Panther에서 새 Envoy 로그 소스 만들기

1. Panther 콘솔의 왼쪽 탐색 바에서 클릭하세요 **구성** > **로그 소스.**
2. 를 선택하고 Panther가 설치된 계정 ID를 입력하십시오. **새로 만들기**.
3. "Envoy"를 검색한 다음 해당 타일을 클릭하세요.
   * 슬라이드 아웃 패널에서 **전송 메커니즘** 우측 상단의 드롭다운은 미리 채워진 상태일 것입니다 **HTTP** 옵션.
4. 를 선택하고 Panther가 설치된 계정 ID를 입력하십시오. **설정 시작**.
5. Panther의 [HTTP 소스 구성에 대한 지침을 따르세요](https://docs.panther.com/ko/data-transports/http#how-to-set-up-an-http-log-source-in-panther)5단계부터 시작하여.
   * 설정할 때 **인증 방법** 소스에 대해, 우리는 [**공유 비밀(Shared Secret)**](https://docs.panther.com/ko/data-transports/http#shared-secret). 헤더 이름과 값을 안전한 위치에 저장하세요. 3단계에서 필요합니다.
   * 이 소스로 전송된 페이로드는 다음의 적용을 받습니다 [모든 HTTP 소스에 대한 페이로드 요구사항](https://docs.panther.com/ko/data-transports/http#payload-requirements).
   * HTTP 엔드포인트 생성이 완료될 때까지 다음 단계로 진행하지 마세요.

### 2단계: Envoy 로깅 구성

{% hint style="info" %}
필드를 추가하거나 제거하여 Envoy 로그를 사용자화할 수 있지만, Panther의 [Envoy.Access 스키마](#envoy.access) 는 기본 로그 형식을 지원하도록 설계되었습니다. 분류 실패를 방지하려면 로그 구성에 기본 형식을 사용하세요.
{% endhint %}

1. 다음 항목을 `envoy.yml` 구성 파일에 추가하세요:
   * 루트 레벨에서 다음 스니펫을 추가하여 관리자 액세스 로깅을 활성화하세요:

     ```yaml
     admin:
       access_log_path: "access.log"
     ```
   * resources 섹션 내에서 액세스 로깅을 활성화하려는 각 리소스에 다음 스니펫을 추가하세요:

     ```yaml
      access_log:
      - name: envoy.access_loggers.file
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
          path: "access.log"
     ```

{% hint style="info" %}
액세스 로그 파일 경로를 사용자화한 경우 (`access.log` 위), Fluent Bit 구성에서 적절한 위치를 가리키도록 설정했는지 확인하세요.
{% endhint %}

2. 업데이트된 구성 파일을 가리키도록 Envoy 프록시를 재시작하려면 다음을 실행하세요 `envoy -c envoy.yml`.

### 3단계: Fluent Bit 구성

1. 다음을 따르세요 [Fluent Bit 시작 안내](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit) Fluent Bit를 서비스로 설치하려면.
2. 생성하세요 [Fluent Bit 구성 파일](https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/classic-mode/configuration-file), 다음 필드를 설정하세요:

   * `[INPUT]` 변수:
     * **이름:** : 데이터 레이크 백엔드의 유형입니다. `tail`.
     * **경로**: 로그 파일 경로로 설정하세요.
     * **파서**: 다음으로 설정 `envoy`.
   * `[OUTPUT]` 변수:
     * **호스트**: Panther URL을 입력하세요.
       * 예: `logs.instance-name.runpanther.net`
     * **URI**: HTTP Source 수집 URL의 끝부분(이 프로세스의 1단계에서 생성된)을 입력하세요. 이것은로 시작합니다 `/http/`.
       * 예: `/http/cb015ee4-543c-4489-9f4b-testaa16d7a`
     * **헤더**: Panther 콘솔에서 1단계에서 HTTP 소스를 구성할 때 생성한 헤더 이름과 생성한 시크릿을 입력하세요.
     * **Format**: 다음으로 설정 `json_lines`
     * **이름**: 다음으로 설정 `http`.
     * **TLS**: 다음으로 설정 `켜기`.
     * **포트**: 다음으로 설정 `443`.

   ```editorconfig
   [SERVICE]
       Flush      1
   [INPUT]
       Name       tail
       # 이 경로는 envoy.yml 구성에 따라 달라집니다
       경로       /var/log/envoy/access.log
       파서     envoy

   [OUTPUT]
       Name       http
       Match      *
       호스트       logs.pre-alpha.runpanther.net
       Port       443
       URI        /http/6897ec53-9c4c-4fc7-a8c8-faf7b29571de
       # x-sender-header 이름이 헤더 이름과 일치하는지 확인하세요
       # Panther에서 HTTP 소스를 생성할 때 제공한 이름과
       Header     x-sender-header {YOUR_SECRET_HERE}
       Format     json_lines
       TLS        On
       TLS.Verify On
   ```
3. 신규 구성 파일 경로와 `parsers.conf` 파일의 경로를 전달하여 Fluent Bit을 시작하세요. 해당 `envoy` 파서는 Fluent Bit에 기본 파서 구성으로 포함되어 제공됩니다.
   * 예: `fluent-bit -c fluent.conf -R /var/etc/fluent-bit/parsers.conf`

## 지원되는 로그 유형

### Envoy.Access

다음은 Envoy 액세스 로그 스키마를 정의합니다:

```yaml
schema: Envoy.Access
description: FluentBit을 사용한 HTTP상의 Envoy 액세스 로그
필드:
  - name: start_time
    description: 요청의 시작 시간.
    type: timestamp
    timeFormats:
      - rfc3339
    isEventTime: true
  - name: method
    description: GET, POST 등과 같은 HTTP 요청 메서드.
    type: string
  - name: path
    description: 요청의 URI 경로.
    type: string
  - 이름: protocol
    description: HTTP 프로토콜 버전.
    type: string
  - 이름: code
    description: 응답의 HTTP 상태 코드.
    type: string
  - name: response_flags
    description: 응답과 관련된 추가 플래그.
    type: string
  - name: bytes_received
    description: 클라이언트로부터 수신된 바이트 수.
    type: string
  - name: bytes_sent
    description: 클라이언트로 전송된 바이트 수.
    type: string
  - name: duration
    description: 요청의 전체 소요 시간.
    type: string
  - name: x_envoy_upstream_service_time
    description: 업스트림 서비스에서 소비된 시간.
    type: string
  - name: x_forwarded_for
    description: X-Forwarded-For 헤더(존재하는 경우).
    type: string
  - name: user_agent
    description: 요청 헤더의 User-agent 문자열.
    type: string
  - name: request_id
    description: 요청 ID 헤더 값.
    type: string
  - name: authority
    description: authority 헤더 값.
    type: string
  - name: upstream_host
    description: 요청에 대해 선택된 업스트림 호스트.
    type: string
```
