> 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/custom-log-types/csv-parser.md).

# CSV 로그 파서

## 개요

다음을 사용하여 `csv` 로그 파서를 사용하면 CSV 파일의 각 행이 키를 값에 매핑하는 단순한 JSON 객체로 변환되어 파싱됩니다. 이를 위해 각 열에는 이름을 지정해야 합니다.

## 헤더가 없는 CSV 로그

헤더 행이 없는 CSV 로그를 파싱하려면 Panther가 각 열에 어떤 이름을 지정할지 알아야 합니다.

로그가 year, month, day, time, action, ip\_address, message의 7개 열을 가진 CSV라고 가정해 봅시다. 이 파일의 예시 행은 다음과 같을 수 있습니다:

```
# 20200901용 액세스 로그
2020,09,01,10:35:23, SEND ,192.168.1.3,"PING"
2020,09,01,10:35:25, RECV ,192.168.1.3,"PONG"
2020,09,01,10:35:25, RESTART ,-,"System restarts"
```

다음을 사용합니다 *LogSchema* 로그 유형을 정의하기 위해:

{% tabs %}
{% tab title="콘솔 " %}
Panther 콘솔에서는 다음을 따릅니다 [수동으로 사용자 지정 스키마를 만드는 방법 안내](/ko/data-onboarding/custom-log-types.md#how-to-create-a-custom-schema-manually), 다음을 선택하여 **CSV** 파서.

<figure><img src="/files/3dcce33ec60397fb97a4c7aa36908f3bed256e3d" alt="Under a &#x22;Parser&#x22; header is a form with various fields, including &#x22;Has Header,&#x22; &#x22;Delimiter,&#x22; &#x22;Columns,&#x22; &#x22;Empty Values,&#x22; and more."><figcaption></figcaption></figure>

다음 **필드 및 인디케이터** 섹션(아래의 **파서** 섹션에서 스크린샷 위에 표시된 대로, 다음과 같이 필드를 정의합니다:

```yaml
fields:
- name: timestamp
  type: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
  required: true
- 이름: action
  type: string
  required: true
- 이름: ip_address
  type: string
  indicators: [ip]
- 이름: message
  type: string
```

{% endtab %}

{% tab title="전체 YAML 표현" %}

```yaml
파서:
  csv:
    # CSV 파일은 다양한 형식으로 존재하며, 각 행을 분리할 구분 문자를 선택할 수 있습니다
    delimiter: ","
    # 값 주변의 공백을 제거
    trimSpace: true
    # 'columns' 배열의 이름이 각 행의 열에 매핑됩니다.
    # 열을 건너뛰고 싶다면 같은 인덱스의 이름을 빈 문자열("")로 설정할 수 있습니다
    columns:
    - year
    - month
    - day
    - time
    - action
    - ip_address
    - message
    # 접두사(예: 주석)로 시작하는 줄은 건너뜁니다
    skipPrefix: "# "
    # CSV 파일은 때때로 누락되었거나 N/A인 데이터를 위해 자리표시자 값을 사용합니다.
    # 이러한 값은 'emptyValues'로 정의할 수 있으며, 그러면 무시됩니다.
    emptyValues: ["-"]
    # 'expandFields' 지시문은 생성된 필드를 키/값 쌍에 삽입하는 템플릿 문자열을 렌더링합니다
    expandFields:
      # 타임스탬프가 여러 열에 걸쳐 분리되어 있으므로, RFC3339 형식으로 다시 조합해야 합니다
      # 다음은 CSV 값의 필드를 대체하여 'timestamp' 필드를 추가합니다
      timestamp: '%{year}-%{month}-%{day}T%{time}Z'
fields:
- name: timestamp
  type: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
  required: true
- 이름: action
  type: string
  required: true
- 이름: ip_address
  type: string
  indicators: [ip]
- 이름: message
  type: string
```

{% endtab %}
{% endtabs %}

## 헤더가 있는 CSV 로그

헤더 행으로 시작하는 CSV 파일을 파싱하려면 두 가지 옵션이 있습니다:

* 헤더에 정의된 이름을 JSON 필드 이름으로 사용합니다
* 헤더를 무시하고 열 이름을 명시적으로 정의합니다 [헤더 없는 CSV 파일에서 하듯이](#csv-logs-without-header)

{% hint style="warning" %}
CSV 파일에 헤더가 있고 열을 명시적으로 정의하지 않는 경우(대신 헤더에 의해 정의되도록 두는 경우), 이 스키마를 다른 스키마와 같은 로그 소스(또는 단일 S3 접두사)에 함께 결합하지 마십시오. 그렇게 하면 로그가 잘못 분류될 수 있습니다.
{% endhint %}

헤더의 이름을 사용하려면 파서 구성은 다음과 같아야 합니다:

```yaml
파서:
  csv:
    delimiter: "," 
    # 'columns' 필드를 지정하지 않고 'hasHeader'를 true로 설정하면,
    # Panther가 헤더의 값에서 열 이름을 설정하도록 지시합니다.
    hasHeader: true
    # 열 이름을 바꾸고 싶다면 'expandFields' 지시문을 사용할 수 있습니다
    expandFields:
      # 헤더에 '$cost'가 열 이름으로 포함되어 있고 이를 'cost_us_dollars'로 '정규화'하고 싶다고 가정해 봅시다
      "cost_us_dollars": '%{$cost}'
```

헤더를 무시하고 열 이름 집합을 정의하려면 다음을 사용합니다:

```yaml
파서:
  csv:
    delimiter: "," 
    # 'columns' 필드를 지정하면서 'hasHeader'를 true로 설정하면, 
    # Panther가 헤더를 무시하고 'columns' 배열의 이름을 사용하도록 지시합니다
    hasHeader: true
    columns:
    - foo
    - bar
    - baz
```


---

# 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/custom-log-types/csv-parser.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.
