# pantherlog 도구

## 개요

다음을 사용할 수 있습니다 `pantherlog`라는 CLI 도구를 사용하여 Custom Logs와 작업할 수 있습니다. 이 도구는 Panther가 관리하는 스키마 또는 [사용자 지정 스키마](/ko/data-onboarding/custom-log-types.md)를 사용하여 로그를 구문 분석하고, 샘플 로그를 사용해 사용자 지정 스키마를 추론합니다.

대신 Panther Console에서 사용자 지정 로그를 사용하는 방법은 다음을 참조하세요. [사용자 지정 로그](/ko/data-onboarding/custom-log-types.md) 문서.

### pantherlog 제한 사항

* 아래의 다음 섹션을 참조하세요. [추론 제한 사항](#infer-limitations) Run Panther AI [테스트 제한 사항](#test-limitations) 섹션.

## 다운로드

다음 링크에서 최신 버전을 다운로드하세요:

<table data-column-title-hidden data-view="cards"><thead><tr><th align="center"></th><th align="center"></th></tr></thead><tbody><tr><td align="center"><strong>Windows</strong></td><td align="center"><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/windows-amd64-pantherlog.exe.zip">amd64</a></p><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/windows-arm64-pantherlog.exe.zip">arm64</a></p></td></tr><tr><td align="center"><strong>Darwin/MacOS</strong></td><td align="center"><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/darwin-amd64-pantherlog.zip">amd64</a> (Intel)</p><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/darwin-arm64-pantherlog.zip">arm64</a> (Apple Silicon)</p></td></tr><tr><td align="center"><strong>Linux</strong></td><td align="center"><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/linux-amd64-pantherlog.zip">amd64</a></p><p><a href="https://panther-community-us-east-1.s3.amazonaws.com/latest/tools/linux-arm64-pantherlog.zip">arm64</a></p></td></tr></tbody></table>

## `list-schemas`: Panther가 관리하는 스키마 목록 표시

pantherlog의 `list-schemas` 명령을 사용하여 Panther의 관리형 스키마를 나열할 수 있습니다.

```
./pantherlog list-schemas
```

## `export-schemas`: Panther가 관리하는 스키마 내보내기

pantherlog의 `export-schemas` 명령을 사용하여 Panther가 관리하는 스키마를 로컬 디렉터리로 내보내거나 터미널에 출력할 수 있습니다.

### 스키마를 로컬 디렉터리로 내보내기

```
./pantherlog export-schemas --path directory-name
```

* 만약 `directory-name` 가 존재하지 않으면 생성됩니다.
* 참고로 `-p` 를 대신 사용해도 됩니다. `--path`.

### 스키마 출력

스키마를 `stdout` 로컬 디렉터리로 내보내는 대신 출력하려면 대시(-)를 사용하세요.

```
./pantherlog export-schemas -p -
```

### 선택한 스키마 내보내기

다음을 사용하여 내보낼 스키마를 필터링할 수 있습니다. `-s` 옵션과 함께 내보내려는 스키마 이름을 쉼표로 구분하여 지정합니다.

```
./pantherlog export-schemas --path ./managed-schemas -s 'AWS.ALB,Slack.AuditLogs'
```

## `infer`: JSON 로그 샘플로부터 스키마 생성

pantherlog를 사용하여 [줄바꿈으로 구분된 JSON](https://jsonlines.org/) 형식의 샘플 파일로부터 스키마 파일을 생성할 수 있습니다. 이 도구는 제공된 로그를 스캔하고 추론된 스키마를 다음에 출력합니다. `stdout`.

예를 들어, 다음 로그의 스키마를 추론하고자 하면 `sample_logs.jsonl` 를 출력 대상으로 하려면 `schema.yml`다음을 사용하세요:

```
$ ./pantherlog infer --name SchemaName sample_logs.jsonl > schema.yml
```

YAML 키와 값은 대소문자를 구분한다는 점에 유의하세요. 이 도구는 여러 타임스탬프 형식을 추론하려고 시도합니다. 스키마 추론에 대해 더 알아보려면 [사용자 지정 로그](/ko/data-onboarding/custom-log-types.md#automatically-infer-the-schema-in-panther).

{% embed url="<https://www.loom.com/share/5479e9c46f914c03bff4da0464f30956>" %}
샘플 로그에서 스키마를 추론하는 워크플로
{% endembed %}

### `infer` 제한 사항

the `infer` 명령은 어떤 타임스탬프 필드도 다음으로 표시하지 않습니다. `isEventTime:true`. 적절한 `timestamp` 필드를 선택하고 다음으로 표시하세요. `isEventTime:true`. 다음에 대한 자세한 내용은 `isEventTime:true`, 다음을 참조하세요. [Log Schema Reference의 Timestamps 섹션](/ko/data-onboarding/custom-log-types/reference.md#timestamps).

the `infer` 명령은 다음 유형의 [지표](/ko/search/panther-fields.md#indicator-fields): `ip`, `aws_arn`, `url`, `email`, `hash` 다이제스트(`MD5`, `SHA1` Run Panther AI `SHA2`) 및 `mac`만 추론할 수 있습니다. 필드를 검토하고 필요에 따라 더 많은 지표를 추가하세요.

다음으로 생성된 스키마를 검토하는 것이 강력히 권장됩니다. `infer` 명령, 그리고 운영 환경에 배포하기 전에 적절히 편집하세요.

## `parse`: 스키마 검증

이 도구를 사용하여 스키마 파일을 검증하고 로그 파일을 파싱하는 데 사용할 수 있습니다. 로그 파일의 이벤트는 줄바꿈으로 구분되어야 한다는 점에 유의하세요. 처리된 로그는 다음으로 작성되고 `stdout` 오류는 다음으로 작성됩니다. `stderr`.

예를 들어, 다음의 로그를 파싱하려면 `sample_logs.jsonl` 와 함께 로그 스키마를 사용하여 `schema.yml`다음을 사용하세요:

```
$ ./pantherlog parse --path schema.yml --schemas Schema.Name sample_logs.jsonl
```

이 도구는 입력을 다음을 통해서도 받을 수 있습니다. `stdin` 이므로 파이프라인에서 사용할 수 있습니다:

```
$ cat sample_logs.jsonl | ./pantherlog parse --path schema.yml
```

## `test`: 스키마에 대한 테스트 실행

pantherlog를 사용하여 사용자 지정 스키마에 대한 단위 테스트를 실행할 수 있습니다. 다음에 정의된 테스트를 실행하려면 `schema_tests.yml` 파일에 정의된 사용자 지정 스키마를 `schema.yml`사용하려면 다음을 실행합니다:

```
$ ./pantherlog test schema.yml schema_tests.yml
```

첫 번째 인수는 스키마 YAML 파일이 포함된 파일 또는 디렉터리입니다. 나머지 인수는 실행할 테스트 파일입니다. 테스트 파일 인수를 지정하지 않고 첫 번째 인수가 디렉터리인 경우, 도구는 다음 접미사를 가진 YAML 파일에서 테스트를 찾습니다. `_tests.yml` 또는 `_tests.yaml` 접미사.

### 스키마 테스트 파일 만들기

테스트 파일에는 파싱할 이벤트를 포함하는 `input` 키와 `결과` 키에 예상 결과를 포함하세요. pantherlog `test` 명령은 스키마가 오류 없이 이벤트를 파싱할 수 있는지, 그리고 정규화된 이벤트가 예상 결과와 일치하는지 확인합니다.

{% hint style="info" %}
the `결과` event에는 다음과 같은 모든 항목이 포함되어야 합니다. [Panther 표준 필드](/ko/search/panther-fields.md) 파싱 중 이벤트에 주입될 것으로 예상되는 필드, 예를 들어 `p_log_type`.
{% endhint %}

를 주의하세요. [다음을 사용하는 방법에 대한 이 지침을 참고하세요. `timeFormats` 스키마 테스트에서](/ko/data-onboarding/custom-log-types/reference.md#working-with-timeformats-in-schema-tests).

{% hint style="info" %}
하나의 스키마에 대해 여러 테스트를 작성하는 예는 Panther의 Knowledge Base에 있는 다음 문서를 참조하세요: [하나의 스키마에 대해 여러 pantherlog 테스트를 어떻게 작성하나요?](https://help.panther.com/Data_Sources/Custom_Logs/How_can_I_write_multiple_pantherlog_tests_for_a_schema%3F)
{% endhint %}

예시:

{% tabs %}
{% tab title="schema\_tests.yml" %}

```json
# 스키마 또는 로그 유형을 이름 지을 때는 camelCase를 사용하세요
name: Custom Log Test Name
logType: Custom.SampleLog.V1
input: |
  {
    "method": "GET",
    "path": "/-/metrics",
    "format": "html",
    "controller": "MetricsController",
    "action": "index",
    "status": 200,
    "params": [],
    "remote_ip": "1.1.1.1",
    "user_id": null,
    "username": null,
    "ua": null,
    "queue_duration_s": null,
    "correlation_id": "c01ce2c1-d9e3-4e69-bfa3-b27e50af0268",
    "cpu_s": 0.05,
    "db_duration_s": 0,
    "view_duration_s": 0.00039,
    "duration_s": 0.0459,
    "tag": "test",
    "time": "2019-11-14T13:12:46.156Z"
  }

result: |
  {
    "action": "index",
    "controller": "MetricsController",
    "correlation_id": "c01ce2c1-d9e3-4e69-bfa3-b27e50af0268",
    "cpu_s": 0.05,
    "db_duration_s": 0,
    "duration_s": 0.0459,
    "format": "html",
    "method": "GET",
    "path": "/-/metrics",
    "remote_ip": "1.1.1.1",
    "status": 200,
    "tag": "test",
    "time": "2019-11-14T13:12:46.156Z",
    "view_duration_s": 0.00039,
    "p_log_type": "Custom.SampleLog.V1",
    "p_row_id": "acde48001122a480ca9eda991001",
    "p_event_time": "2019-11-14T13:12:46.156Z",
    "p_parse_time": "2022-04-04T16:12:41.059224Z",
    "p_any_ip_addresses": [
        "1.1.1.1"
    ]
  }
```

{% endtab %}

{% tab title="schema.yml" %}

```yaml
버전: 0
schema: Custom.SampleLog.V1
필드:
- name: action
  필수: true
  유형: string
- name: controller
  필수: true
  유형: string
- name: correlation_id
  필수: true
  유형: string
- name: cpu_s
  필수: true
  type: float
- name: db_duration_s
  필수: true
  유형: bigint
- name: duration_s
  필수: true
  type: float
- name: format
  필수: true
  유형: string
- name: method
  필수: true
  유형: string
- name: path
  필수: true
  유형: string
- name: remote_ip
  필수: true
  유형: string
  indicators:
   - ip
- 이름: status
  필수: true
  유형: bigint
- name: tag
  필수: false
  유형: string
- 이름: time
  필수: true
  유형: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
- name: view_duration_s
  필수: true
  type: float
```

{% endtab %}
{% endtabs %}

### `test` 제한 사항

* the `test` 명령은 JSON 이벤트만 지원합니다.

## PAT를 통해 스키마 업로드

Panther Analysis Tool(PAT)을 통해 스키마를 업로드하는 방법에 대한 정보는 다음을 참조하세요. [Custom Logs: Panther Analysis Tool로 로그 스키마 업로드](/ko/data-onboarding/custom-log-types.md#uploading-log-schemas-with-the-panther-analysis-tool).


---

# 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/panther/pantherlog.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.
