> 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 ,-,"시스템 재시작"
```

다음의 *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:
- 이름: timestamp
  type: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
  required: true
- 이름: action
  type: string
  required: true
- 이름: ip_address
  type: string
  indicators: [ip]
- name: 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:
- 이름: timestamp
  type: timestamp
  timeFormats: 
   - rfc3339
  isEventTime: true
  required: true
- 이름: action
  type: string
  required: true
- 이름: ip_address
  type: string
  indicators: [ip]
- name: 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.
