# Docker 로그

## 개요

Panther는 수집을 지원합니다 [Docker 이벤트](https://docs.docker.com/engine/reference/commandline/events/) 를 스트리밍하여 로그를 [HTTP 소스](https://docs.panther.com/ko/data-onboarding/data-transports/http) 전달된 후 [Fluent Bit.](https://docs.fluentbit.io/manual/)

## Panther에 Docker 이벤트를 온보딩하는 방법

### 1단계: Panther에 새 Docker 이벤트 로그 소스 만들기

1. Panther Console의 왼쪽 탐색 표시줄에서 **구성** > **Log Sources를 클릭합니다.**
2. 을 클릭합니다 **새로 만들기**.
3. "Docker Events"를 검색한 다음 해당 타일을 클릭합니다.
   * 슬라이드아웃 패널에서 **전송 메커니즘** 오른쪽 상단의 드롭다운은 다음 옵션으로 미리 채워집니다. **HTTP** 옵션.
4. 을 클릭합니다 **Start Setup**.\
   ![In the new log source onboarding flow in the Panther Console, the Docker Events page is shown. The "Transport Mechanism" dropdown has a value of "HTTP," and to its right is a "Start Setup" button.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-6927f28a036ffd191e4ea1467aee2752b2a4c4b5%2FScreenshot%202023-07-31%20at%203.31.46%20PM.png?alt=media)
5. Panther의 [HTTP Source 구성 지침을 따라](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).
   * 이 소스로 전송되는 페이로드는 다음의 적용을 받습니다. [모든 HTTP 소스에 대한 페이로드 요구사항](https://docs.panther.com/ko/data-transports/http#payload-requirements).
   * HTTP 엔드포인트 생성이 완료될 때까지 다음 단계로 진행하지 마세요.

HTTP 소스를 생성한 후 Panther 콘솔에 HTTP 소스 URL이 표시됩니다. 다음 단계에서 필요하므로 이 값을 सुरक्षित한 위치에 저장하세요.

### 2단계: 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).
   * 아래에서 Linux 및 macOS용 샘플 구성 파일을 확인하세요. [예제 구성 파일](#example-configuration-files).
3. 새 구성 파일 경로를 전달하여 Fluent Bit을 시작하세요.
   * 다음의 경로를 포함해야 합니다. `parser.conf` 파일에는 다음이 포함되어 있습니다. `docker` 파서가 포함되어야 합니다. 이는 fluent-bit에 기본적으로 포함됩니다. Linux에서는 다음 위치에서 찾을 수 있습니다. `/etc/fluent-bit/parsers.conf`.
     * 예시: `fluent-bit -c fluentbit.conf -R /etc/fluent-bit/parsers.conf`

#### 예제 구성 파일

{% tabs %}
{% tab title="Linux" %}
Fluent Bit 구성 파일에서 다음을 설정합니다:

* `[INPUT]` variables:
  * **Name**: 다음으로 설정합니다 `docker_events`.
  * **Parser**: 다음으로 설정합니다 `docker`.
* `[OUTPUT]` variables:
  * **Host**: Panther URL을 입력하세요.
    * 예시: `logs.instance-name.runpanther.net`
  * **URI**: 이 프로세스의 1단계에서 생성된 HTTP Source 수집 URL의 끝부분을 입력하세요. 다음으로 시작합니다. `/http/`.
    * 예시: `/http/cb015ee4-543c-4489-9f4b-testaa16d7a`
  * **Header**: 1단계에서 Panther Console에서 HTTP 소스를 구성할 때 생성한 헤더 이름과 생성한 비밀 키를 입력하세요.
  * **Name**: 다음으로 설정하세요. `http`.
  * **TLS**: 다음으로 설정하세요. `ON`.
  * **Port**: 다음으로 설정하세요. `443`.

```editorconfig
[SERVICE]
  flush      1

[INPUT]
  name       docker_events
  parser     docker

[OUTPUT]
  name       http
  match      *
  host       logs.instance.runpanther.net
  port       443
  URI        /http/70c55034-13f1-4e08-a018-test5f2bb0a8
  Header     x-panther-secret {YOUR_SECRET_HERE}
  Format     json_lines
  TLS        on
  TLS.Verify on
```

{% endtab %}

{% tab title="macOS" %}
Fluent Bit 구성 파일에서 다음을 설정합니다:

* `[INPUT]` variables:
  * **Name**: 다음으로 설정합니다 `docker_events`.
    * macOS에서는 `docker_events` 은 fluent-bit에서 지원되지 않습니다. 대신 다음을 사용할 수 있습니다. [Exec 입력 플러그인](https://docs.fluentbit.io/manual/pipeline/inputs/exec). 아래의 macOS 샘플 구성을 참조하세요.
  * **Parser**: 다음으로 설정합니다 `docker`.
* `[OUTPUT]` variables:
  * **Host**: Panther URL을 입력하세요.
    * 예시: `logs.instance-name.runpanther.net`
  * **URI**: 이 프로세스의 1단계에서 생성된 HTTP 소스 URL의 끝부분을 다음으로 시작하여 입력합니다. `/http/`.
    * 예시: `/http/cb015ee4-543c-4489-9f4b-testaa16d7a`
  * **Header**: 1단계에서 Panther Console에서 HTTP 소스를 구성할 때 생성한 헤더 이름과 생성한 비밀 키를 입력하세요.
  * **Name**: 다음으로 설정하세요. `http`.
  * **TLS**: 다음으로 설정하세요. `ON`.
  * **Port**: 다음으로 설정하세요. `443`.

```editorconfig
[SERVICE]
  flush      1

[INPUT]
  name         exec
  parser       docker
  Command      docker events --since 10s --until 0s --format '{{json .}}'
  Interval_Sec 10

[OUTPUT]
  name       http
  match      *
  host       logs.instance.runpanther.net
  port       443
  URI        /http/70c55034-13f1-4e08-a018-2c005f2bb0a8
  Header     x-panther-secret {YOUR_SECRET_HERE}
  Format     json_lines
  TLS        on
  TLS.Verify on
```

{% endtab %}
{% endtabs %}

## 지원되는 로그 유형

### Docker.Events

다음은 Docker 이벤트 로그 스키마를 정의합니다:

```yaml
schema: Docker.Events
description: 컨테이너, 이미지, 네트워크 및 볼륨에 대한 시스템 수준 관리 작업을 감사하기 위한 Docker 이벤트
referenceURL: https://docs.docker.com/engine/reference/commandline/events/
필드:
  - 이름: status
    description: 이 이벤트의 작업 상태를 나타내는 문자열
    유형: string
  - name: id
    description: 이벤트 ID
    유형: string
  - name: from
    description: 이벤트가 발생한 출처의 컨텍스트
    유형: string
  - name: Type
    description: 작업 대상이 되는 객체의 유형입니다. 객체 유형 목록은 참조를 확인하세요
    유형: string
  - name: Action
    description: 수행된 작업입니다. 유형에 따라 가능한 작업이 다릅니다. 이벤트 유형 목록은 참조를 확인하세요
    유형: string
  - name: Actor
    description: 이벤트를 수행하는 주체입니다. Docker 맥락에서는 반드시 최종 사용자가 아니라 컨테이너 자체일 수도 있습니다
    type: object
    필드:
      - name: ID
        description: 주체 ID
        유형: string
        indicators:
          - actor_id
      - name: Attributes
        description: 이벤트별 세부 정보
        유형: json
  - name: scope
    description: 이벤트 유형에 따라 범위가 다릅니다. 로컬 범위 이벤트는 해당 이벤트가 발생한 노드에서만 보이며, swarm 범위 이벤트는 모든 관리자에서 보입니다.
    유형: string
  - 이름: time
    필수: true
    description: 이벤트가 발생한 시각(유닉스 초)
    유형: timestamp
    timeFormats:
      - unix
    isEventTime: true
  - name: timeNano
    description: 이벤트 시간(나노초 단위)
    유형: string
```
