# Fastmatch 로그 파서

## 개요

그 `fastmatch` parser는 로그 줄 내 필드의 위치를 지정하는 간단한 문자열 패턴을 사용합니다. 이름에서 알 수 있듯이 매우 빠르며, 텍스트 로그를 파싱하는 데 선호되는 방법으로 간주해야 합니다. 필드의 순서가 알려진 대부분의 구조화된 텍스트 로그 경우를 처리할 수 있습니다. 사실 매우 빠르기 때문에 순서대로 테스트될 여러 패턴을 지정할 수 있어, 로그 줄 구조에 몇 가지 변형이 있는 경우도 '해결'할 수 있습니다.

### fastmatch를 사용한 예제

다음 예제 로그 줄은 Apache Common Log 형식을 사용합니다:

```
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
```

다음은 다음을 사용해 이 로그 유형에 대한 로그 스키마를 정의하는 방법입니다 `fastmatch`:

{% tabs %}
{% tab title="콘솔 " %}
Panther 콘솔에서는 다음을 따라 [커스텀 스키마를 수동으로 만드는 방법 지침](/ko/data-onboarding/custom-log-types.md#how-to-create-a-custom-schema-manually)을 선택하여 **FastMatch** parser.

<figure><img src="/files/f6a993d3e39f0c3e2e63b2f54d8885f16fd07dc4" alt="In a &#x22;Schema&#x22; section, &#x22;FastMatch&#x22; is selected for a Parser field. There are various form fields shown, such as Match Patterns, Empty Values, and Skip Prefix."><figcaption></figcaption></figure>

다음 **필드 및 표시기** 섹션(위 스크린샷에 표시된 **파서** 섹션 아래)에서 다음 필드를 정의합니다:

```yaml
fields:
  - 이름: remote_ip
    type: string
    indicators:
      - ip
  - 이름: identity
    type: string
  - 이름: user
    type: string
  - name: timestamp
    type: timestamp
    isEventTime: true
    timeFormats:
     - '%d/%b/%Y:%H:%M:%S %z'
  - 이름: method
    type: string
  - name: request_uri
    type: string
  - 이름: protocol
    type: string
  - 이름: status
    유형: int
  - 이름: bytes_sent
    type: bigint
```

{% endtab %}

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

```yaml
parser:
  fastmatch:
    # 일치시킬 패턴 배열을 정의합니다.
    # 이 예제에서는 모든 줄의 로그 형식이 같기 때문에 하나의 패턴만 사용합니다.
    # Apache Extended Log 형식을 포함하려면 추가 패턴을 제공할 수 있습니다.
    match:
      - '%{remote_ip} %{identity} %{user} [%{timestamp}] "%{method} %{request_uri} %{protocol}" %{status} %{bytes_sent}'
    emptyValues: [ '-' ] # `-` 문자열 값은 null로 간주하도록 지정합니다
fields:
  - 이름: remote_ip
    type: string
    indicators:
      - ip
  - 이름: identity
    type: string
  - 이름: user
    type: string
  - name: timestamp
    type: timestamp
    isEventTime: true
    timeFormats:
     - '%d/%b/%Y:%H:%M:%S %z'
  - 이름: method
    type: string
  - name: request_uri
    type: string
  - 이름: protocol
    type: string
  - 이름: status
    유형: int
  - 이름: bytes_sent
    type: bigint
```

{% endtab %}
{% endtabs %}

## fastmatch 패턴 이해하기

패턴은 `%{field_name}` 플레이스홀더를 사용하여 로그 줄에서 필드가 예상되는 위치를 지정합니다. 예를 들어, 다음 텍스트와 일치시키려면:

```
2020-10-10T14:32:05 [FOO_SERVICE@127.0.0.1] [DEBUG] "" Something when wrong
```

다음 패턴을 사용할 수 있습니다(명확성을 위해 작은따옴표로 감쌌습니다):

```yaml
' %{timestamp} [%{service}@%{ip}] [%{log_level}] %{message}'
```

Panther 콘솔에서 스키마를 정의하는 경우, 패턴을 다음 위치에 입력합니다 **일치 패턴** 필드에 포함됩니다:

<figure><img src="/files/3e34dec809b75a31e1e3989cf91287240a6307ef" alt="A &#x22;Match Patterns&#x22; field is shown. Its description is, &#x22;Define patterns to match log entries and extract structured information from unstructured log lines.&#x22;"><figcaption></figcaption></figure>

### 구분자

연속된 두 필드 사이의 텍스트가 그 둘 사이의 '구분자'를 정의합니다. 구분자는 비어 있을 수 없습니다.

위 예제의 패턴에서는 다음을 생략할 수 없습니다 `"@"` 사이의 `service` 및 `ip`.

필드 *이전에 오는* 구분자에는 구분자 텍스트가 포함될 수 없습니다. 위 예제에서는:

* `timestamp` 공백을 포함할 수 없음 `" "`
* `service` 포함할 수 없음 `"@"`
* `ip` 포함할 수 없음 `"] ["`
* `log_level` 포함할 수 없음 `"] "`

### 익명 필드

이름이 없는 필드 플레이스홀더(`%{}`)는 무시됩니다.

### 꼬리 캡처

패턴의 마지막 필드 뒤에 구분자 텍스트가 없으면 *뒤에* 텍스트의 *모든 것* 을 끝까지 캡처합니다. 위 예제에서 `message` 는 다음을 캡처합니다 `"Something when wrong"`

### 따옴표 처리

경우에 따라 필드는 텍스트 안에서 따옴표로 감싸질 수 있습니다:

```
2020-10-10T14:32:05 "내부에 \"이스케이프된 따옴표\"가 있는 인용된 텍스트"
```

이러한 필드를 올바르게 이스케이프 해제하려면 필드 플레이스홀더를 따옴표로 감싸면 됩니다:

```
%{timestamp} "%{message}"
```

이는 작은따옴표와 큰따옴표 모두에 적용됩니다.


---

# 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/data-onboarding/custom-log-types/fastmatch-parser.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.
