> 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/search/scheduled-searches/templated-searches/anomaly-detection-macros.md).

# 행동 분석 및 이상 디택션 템플릿 매크로

## 개요

Panther는 제공합니다 [템플릿 매크로](/ko/search/scheduled-searches/templated-searches.md#how-to-use-template-macros) 로그 데이터 전반에서 비정상적이고 새로운 값을 식별하기 위한 것입니다. 템플릿 매크로를 사용하면 최근 로그 이벤트를 과거 데이터와 비교하여 확립된 정상 범위에서 크게 벗어나는 활동을 식별할 수 있습니다. 이러한 행동 분석 및 이상 디택션 매크로는 사용자 및 엔터티 행동 분석(UEBA) 전략의 일부로 유용할 수 있습니다.

이 매크로는 최근 시간 구간의 데이터를 더 긴 조회 범위의 데이터와 비교하고, 두 데이터 간의 편차 수준을 판단하는 방식으로 작동합니다.

Panther가 제공하는 매크로는 다음과 같습니다:

* `statistical_anomaly`: 수치 필드의 이상치 값을 식별합니다
  * 예: 지난 2주와 비교했을 때 지난 1시간 동안 비정상적으로 많은 트래픽을 전송한 VPC 호스트를 찾습니다.
  * 다음에서 자세히 알아보세요 [statistical\_anomaly](#statistical_anomaly).
* `statistical_anomaly_peer`: 한 [동료 그룹](#peer-group-analysis)
  * 내 수치 필드의 이상치 값을 식별합니다
  * 다음에서 자세히 알아보세요 [statistical\_anomaly\_peer](#statistical_anomaly_peer).
* `new_unique_values`: 지정된 엔터티의 새 값을 식별합니다
  * 예: 지난 30일 동안에는 액세스하지 않았지만 최근 하루 동안 리소스에 액세스한 API 토큰을 찾습니다.
  * 다음에서 자세히 알아보세요 [new\_unique\_values](#new_unique_values).
* `new_unique_values_peer`: 한 [동료 그룹](#peer-group-analysis)
  * 예: EC2 인스턴스가 VPC 그룹 구성원에게는 일반적이지 않은 IP에 연결했는지 감지합니다.
  * 다음에서 자세히 알아보세요 [new\_unique\_values\_peer.](#new_unique_values_peer)

매크로의 소스 코드를 보는 방법 알아보기 [아래](#viewing-the-ueba-macro-source-code).

## 매크로 활성화하기

매크로를 호출하기 전에 Panther 인스턴스에서 사용할 수 있도록 만들어야 합니다. 매크로는 Panther가 관리하는 [저장된 검색](/ko/search/scheduled-searches.md)에서 제공되며, 다음 방법으로 얻을 수 있습니다:

* 콘솔 워크플로에서는 다음을 통해: `PantherManaged.Anomalies` [디택션 Pack](/ko/detections/panther-managed/packs.md)
* CLI 워크플로에서는 다음에서 가져와 [panther-analysis](/ko/panther/detections-repo.md) 를 사용해 업로드합니다 [Panther Analysis Tool (PAT)](/ko/panther/detections-repo/pat.md)

{% tabs %}
{% tab title="콘솔 워크플로" %}
Panther Console에서 매크로를 활성화하려면 `PantherManaged.Anomalies` Pack을 활성화하세요:

1. Panther Console의 왼쪽 탐색 모음에서 **탐지**그다음 **팩**.
2. 다음 **텍스트로 Pack 필터링** 필드에 "Anomaly."를 입력합니다.
3. 오른쪽에서 **Panther 이상 디택션 Pack** 타일의 Enabled 토글을 `켜기`.

<figure><img src="/files/8e471d6db2994228542fd83d476bd9b4610b07aa" alt="Screenshot which shows to to enable a pack. &#x22;Detections&#x22; is selected from the left-side navbar, and the tab is set to &#x22;Packs&#x22;. A user has searched for the string &#x22;anomaly&#x22; in the search bar, returning a single pack named &#x22;Panther Anomaly Detection Pack&#x22;. The user has flipped the toggle widget for the pack at the right-side of the panel to &#x22;On&#x22;."><figcaption></figcaption></figure>
{% endtab %}

{% tab title="CLI 워크플로" %}
매크로는 anomolies.yml 파일을 통해 panther-analysis 저장소에 추가되었습니다 [`anomalies.yml 파일`](https://github.com/panther-labs/panther-analysis/blob/main/queries/macros/anomalies.yml)에서 사용할 예제 SQL 쿼리를 참조하세요. [v3.75.1](https://github.com/panther-labs/panther-analysis/releases/tag/v3.75.1). 이 파일을 자체 Panther 콘텐츠 저장소로 가져오려면 다음 중 하나를 수행하세요:

* 저장소를 다음과 동기화하세요 [릴리스](https://github.com/panther-labs/panther-analysis/releases) v.3.75.1 이상.
* 다음을 다운로드하세요 [`anomalies.yml` 파일을](https://github.com/panther-labs/panther-analysis/blob/main/queries/macros/anomalies.yml) GitHub에서 수동으로 내려받아 저장소에 저장합니다.
  * panther-analysis와 전체 동기화를 수행하지 않으려는 경우 이 방법이 적합할 수 있습니다.

한번 `anomalies.yml` 가 저장소에 있으면 다음을 사용하여 Panther에 업로드할 수 있습니다 [PAT](/ko/panther/detections-repo/pat.md).
{% endtab %}
{% endtabs %}

## Panther에서 행동 분석 및 이상 디택션 매크로를 사용하는 방법

Panther가 관리하는 행동 분석 및 이상 디택션 매크로를 [데이터 탐색기](/ko/search/data-explorer.md) 아래 지침에 따라 호출할 수 있습니다. 이 과정은 다음과 유사합니다 [다른 쿼리에서 템플릿 매크로 호출하기](/ko/search/scheduled-searches/templated-searches.md#calling-template-macros-in-other-queries) 지침이지만, 행동 분석 및 이상 디택션 템플릿 매크로 사용에 특화되어 있습니다.

1. [Panther 인스턴스에서 매크로 활성화](#enabling-the-macros).
2. Panther Console의 왼쪽 탐색 모음에서 **검색**, 그런 다음 다음을 선택합니다 **데이터 탐색기** 탭.
3. SQL 편집기 상단에 `-- pragma: template` 문을 추가하세요.

{% hint style="info" %}
선택적으로 다음도 추가할 수 있습니다 `--pragma: show macro expanded`. 그러면 매크로가 소스 코드로 확장되며, 쿼리 문제를 해결할 때 유용합니다. 다음을 참조하세요 [템플릿 매크로 디버깅](/ko/search/scheduled-searches/templated-searches.md#debugging-template-macros) 자세한 정보를 보려면.
{% endhint %}

```sql
-- pragma: template
-- pragma: show macro expanded # 선택 사항
```

4. 사용 가능한 매크로 중 하나를 가져오세요:

```sql
{% import 'anomalies' <statistical_anomaly, new_unique_values, 
statistical_anomaly_peer, OR new_unique_values_peer> %}
-- 네 개 모두가 아니라 하나의 매크로만 지정하세요
```

5. 다음을 사용해 하위 쿼리를 정의하세요 [공통 테이블 식(CTE)](https://docs.snowflake.com/en/user-guide/queries-cte). 하위 쿼리는 다음을 충족해야 합니다:
   * `선택` 최소한 다음이 필요합니다:
     * `p_event_time`
     * 엔터티 열. 엔터티는 종종 이메일 주소, 사용자 ID, 애플리케이션 ID, 호스트 이름과 같은 ID이지만, IP 주소와 같은 모든 데이터 형식일 수 있습니다. 이 열은 최상위 필드여야 합니다. 필드가 객체 또는 배열 안에 중첩되어 있으면 `AS` 키워드를 사용해 해당 열의 별칭을 만드세요.
     * 집계 열.  `statistical_anomaly` 쿼리에서는 이 열의 내용이 집계되고 비정상적인 값을 검사합니다.  `new_unique_values` 쿼리에서는 이 열의 내용이 새로운 값을 검사합니다. 엔터티 열과 마찬가지로 이 열도 최상위 필드여야 합니다.
     * (만약 `statistical_anomaly_peer` 또는 `new_unique_values_peer`를 사용 중이라면)  [동료 그룹](#peer-group-analysis) 필드.
   * 다음을 사용하여 `WHERE` 절을 통해 조회 범위를 정의하세요(즉, 짧은 범위와 비교할 기준선을 나타내는 더 긴 시간 기간). 조회 범위는 현재 시점에서 끝나야 하므로, 다음을 사용하는 것이 좋습니다 `p_occurs_since()`. [다음에 대해 자세히 알아보기 `p_occurs_since()` 여기](https://docs.panther.com/search/data-explorer#time-offset-from-present-p_occurs_since).

```sql
with subquery as (
    select 
        user:email as email, -- 엔터티 열
        event_type, -- 집계 열
        p_event_time
    from mytable where p_occurs_since(30d)
),
```

6. 하위 쿼리 아래에서 매크로를 호출하세요:

```sql
{{ <statistical_anomaly, new_unique_values, statistical_anomaly_peer, OR new_unique_values_peer>
(<subquery>, '<entity_col>', ...) }}
```

* 각 매크로의 전체 입력 인수 목록은 다음에서 확인하세요 [행동 분석 및 이상 디택션 매크로 참조](#behavioral-analytics-and-anomaly-detection-macro-reference), 아래.

7. 클릭합니다 **검색 실행**.

### 임시 검색을 넘어

Panther의 행동 분석 및 이상 디택션 쿼리는 위협 헌팅에 유용하지만, 모니터링 시스템으로 사용할 때 더 강력합니다. 쿼리는 [저장된 경우를 제외하고](/ko/search/scheduled-searches.md)로 예약 실행되도록 설정하고, 예약 규칙에 연결할 수 있습니다. 이렇게 하면 비정상적인 활동이 관찰될 때마다 알림을 받을 수 있습니다.

### **전체 예시**

아래에서 모든 매크로를 호출하는 전체 예시를 확인하세요.

{% tabs %}
{% tab title="statistical\_anomaly" %}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#### \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`statistical\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_anomaly\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`를 사용하는 전체 예시

이 쿼리는 지난 1시간 동안 관찰된 VPC 트래픽을 지난 24시간으로 설정된 기준선과 비교하며, 어떤 주소가 비정상적으로 많은 양의 아웃바운드 트래픽을 전송했을 경우 경고합니다. 이는 데이터 유출 행위를 나타낼 수 있습니다.

```sql
-- pragma: template

{% import 'anomalies' statistical_anomaly %}
WITH subquery AS (
  -- 아웃바운드 요청을 찾습니다:
  선택
    p_event_time as p_timeline,
    concat(srcAddr,' -> ',dstAddr,':',dstPort) as traffic,
    *
  FROM
    panther_logs.public.aws_vpcflow
  WHERE
    p_occurs_since('7 day')
    AND dstAddr not like '10.%'
    AND dstPort < 1024
    AND flowDirection = 'egress'
    AND pktDstAwsService is null
),
{{statistical_anomaly('subquery', 'traffic', 'bytes', 'sum', '1', 'hour', 3)}}
```

{% endtab %}

{% tab title="new\_unique\_values" %}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#### \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`new\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_unique\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_values\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`를 사용하는 전체 예시

이 쿼리는 지난 1시간의 로그인 이벤트를 분석하고, 이전 30일 동안 한 번도 본 적이 없는 IP 주소에서 이메일 주소가 로그인에 사용된 사례를 반환합니다.

이 쿼리는 의심스러운 로그인을 식별하는 데 유용할 수 있습니다.

```sql
--pragma: template
--pragma: show macro expanded
{% import 'anomalies' new_unique_values %}

with subquery as (
    select email, src_ip, p_event_time
    from mytable where p_occurs_since(30d)
),
{{ new_unique_values('subquery', 'email', 'src_ip', '1hr') }}
```

{% endtab %}

{% tab title="statistical\_anomaly\_peer" %}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#### \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`statistical\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_anomaly\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_peer\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`를 사용하는 전체 예시

아래 예시는 피어 그룹을 사용하여 한 사용자가 생성한 GitHub 풀 리퀘스트 수를 팀의 다른 구성원이 생성한 풀 리퀘스트 수와 비교합니다.

쿼리는 `where` 필터 절을 사용해 풀 리퀘스트 생성 이벤트만 가져오고, 주말에 생성된 이벤트는 제외합니다. 또한 다음에서 사용자 이름/개발 팀 연결 정보를 가져옵니다 [사용자 지정 조회 테이블](/ko/enrichment/custom.md).

```sql
{% import 'anomalies' statistical_anomaly_peer %}

with logs as (
    select
        p_event_time,
        actor,
        action as action_name
    from panther_logs.public.github_audit
    where p_occurs_since('90d') -- 최근 90일의 데이터
    and action_name = 'pull_request.create' -- 풀 리퀘스트 생성 이벤트만
    and DAYNAME(p_event_time) not in ('Sat', 'Sun') -- 주말 무시
), subquery as (
    select
        logs.p_event_time,
        logs.actor as actor,
        logs.event as event_type
        lut.team as team
    from
        로그
        join
        panther_lookups.public.custom_github_teams as lut
        on logs.actor = lut.actor
),
{{ statistical_anomaly_peer('subquery', 'actor', 'team', 'n', 'count', '1', 'day', 0.1) }}
```

{% endtab %}

{% tab title="new\_unique\_values\_peer" %}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#### \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`new\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_unique\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_values\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_peer\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`를 사용하는 전체 예시

이 예시의 쿼리는 어떤 사용자가 팀의 다른 어떤 사용자도 이전에 사용하지 않은 저장소에서 GitHub 풀 리퀘스트를 생성했는지 확인하려고 합니다.

쿼리는 `where` 필터 절을 사용해 풀 리퀘스트 생성 이벤트만 가져옵니다.  `repo` 열은 새 값을 분석하기 위해 추출됩니다. 또한 쿼리는 다음에서 사용자 이름/개발 팀 연결 정보를 가져옵니다 [사용자 지정 조회 테이블](/ko/enrichment/custom.md).

```sql
{% import 'anomalies' new_unique_values_peer %}

with logs as (
    select
        p_event_time,
        actor,
        action as action_name
        repo,
    from panther_logs.public.github_audit
    where p_occurs_since('90d') -- 최근 90일의 데이터
    and action_name = 'pull_request.create' -- 풀 리퀘스트 생성 이벤트만
), subquery as (
    select
        logs.p_event_time,
        logs.actor as actor,
        logs.event as event_type
        lut.team as team
    from
        로그
        join
        panther_lookups.public.custom_github_teams as lut
        on logs.actor = lut.actor
),
{{ new_unique_values_peer('subquery', 'actor', 'team', 'repo', '1d') }}
```

{% endtab %}
{% endtabs %}

## 매크로 소스 코드 보기

매크로를 [활성화한 후](#enabling-the-macros), Panther Console 또는 panther-analysis 저장소에서 행동 분석 및 이상 디택션 매크로 소스 코드를 볼 수 있습니다.

{% tabs %}
{% tab title="Panther Console" %}
Panther Console에서 매크로 소스 코드를 보려면:

1. Panther Console의 왼쪽 탐색 모음에서 **저장된 검색**.
2. 다음 이름의 저장된 검색을 찾으세요 `anomalies`를 클릭하세요.\
   ![The saved query containing the macro source code is called "anomalies"](/files/40edfe3aae1c7f3023f87dacfe5d42cb74add227)
   * 다음으로 이동하게 됩니다 [데이터 탐색기](/ko/search/data-explorer.md)여기서 소스 코드를 볼 수 있습니다:\
     ![Opening the "anomalies" query in Data Explorer will display the full macro code](/files/807c5096b954d28913ef935e242d9dc62aca3a69)
     {% endtab %}

{% tab title="panther-analysis 저장소" %}
panther-analysis에서 매크로 소스 코드를 보려면:

* 로컬 Panther 코드 저장소 또는 [Panther의 상위 panther-analysis 저장소에서](https://github.com/panther-labs/panther-analysis/blob/main/queries/macros/anomalies.yml)다음을 확인하세요 [`queries/macros/anomalies.yml` 파일을](https://github.com/panther-labs/panther-analysis/blob/main/queries/macros/anomalies.yml).
  {% endtab %}
  {% endtabs %}

## 피어 그룹 분석

엔터티의 행동을 특히 그 피어의 행동과 비교하는 것이 종종 유용합니다. 예를 들어, 한 엔지니어가 최근에 다른 엔지니어들은 로그인하지 않은 계정에 로그인했는지 확인할 수 있습니다.

Panther는 다음의 피어 버전을 제공합니다 `statistical_anomaly` 및 `new_unique_values` 이러한 분석을 수행하기 위해. 피어 버전에서는 기준 통계가 피어 그룹에 따라 계산된 다음 엔터티의 행동이 기준선과 비교됩니다.

이 쿼리는 비피어 버전과 유사하게 작동하지만, 피어 그룹을 정의하기 위한 추가 매개변수 `group_field`가 추가됩니다. 이는 엔터티를 함께 그룹화하는 데 사용되는 값이 있는 열이어야 합니다. 일반적인 `group_field` 값의 예시는 사용자 역할, 직무 부서, VPC ID, 계정 ID입니다.

## 행동 분석 및 이상 디택션 매크로 참조

아래에서 Panther가 제공하는 매크로 사용 방법에 대한 참고 정보를 확인할 수 있습니다. 별도로 명시되지 않는 한, 모든 입력 인수는 여기에 표시된 순서대로 제공해야 한다고 가정하세요.

### statistical\_anomaly

다음 `statistical_anomaly` macro는 최근 기간 내의 비정상적인 데이터 포인트를 찾기 위해 데이터 세트를 살펴봅니다. CTE를 기본 데이터 세트로 사용하며, 해당 기간 동안 엔터티의 기준 활동을 같은 엔터티의 가장 최근 활동과 비교하고, 이 행동이 얼마나 비정상적인지 계산합니다.

기본 데이터 세트를 제공하고, 어떤 열에 엔터티 이름이 들어 있는지와 데이터 비교에 사용할 열이 무엇인지 지정해야 합니다. 또한 이상을 찾을 최근 기간의 크기도 정의해야 합니다.

#### 입력 인수

다음 각 인수는 아래 표시된 순서대로 매크로에 제공해야 합니다.

<table><thead><tr><th width="174">이름</th><th width="105">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>subquery</code></td><td>문자열</td><td>이전에 정의한 CTE의 이름으로, 매크로가 분석할 데이터를 제공합니다.</td></tr><tr><td><code>entity_field</code></td><td>문자열</td><td>그룹화에 사용할 열의 이름이며, 일반적으로 이름, IP 주소 또는 ID입니다.</td></tr><tr><td><code>agg_field</code></td><td>문자열</td><td>이상치를 검색할 열의 이름입니다.</td></tr><tr><td><code>agg_func</code></td><td>문자열</td><td>시간 기간 내 데이터 집계에 사용할 SQL 함수는 무엇입니까? <code>agg_field</code> 일반적인 값은 <code>count</code>, <code>sum</code>, 및 <code>max</code>.</td></tr><tr><td><code>tmag</code></td><td>문자열</td><td>이상을 찾을 조회 범위의 단위 수입니다. 즉, <strong>1</strong> in "<strong>1</strong> day"의</td></tr><tr><td><code>tunit</code></td><td>문자열</td><td>이상을 찾을 조회 범위의 시간 단위입니다. 즉, <strong>day</strong> "1 <strong>day</strong>"에서. 단수형이어야 합니다(끝에 "s" 없음).</td></tr><tr><td><code>zscore</code></td><td>숫자</td><td>이상치 임계값; 계산된 <code>zscore</code> 값이 이 값보다 높지 않으면 결과가 반환되지 않습니다.</td></tr></tbody></table>

#### 반환

매크로 실행 후 반환되는 테이블에는 다음 열이 포함됩니다:

<table><thead><tr><th width="194">이름</th><th width="131">데이터 유형</th><th width="424">설명</th></tr></thead><tbody><tr><td><code>N</code></td><td>숫자</td><td>의 데이터 값으로, <code>agg_field</code>에 의해 집계된 <code>agg_func</code>이며, 주어진 엔터티의 조회 기간 동안의 값입니다.</td></tr><tr><td><code>t1</code></td><td>타임스탬프</td><td>조회 기간의 시작.</td></tr><tr><td><code>t2</code></td><td>타임스탬프</td><td>조회 기간의 끝.</td></tr><tr><td><code>&#x3C;entity_field></code></td><td>임의의</td><td>선택한 <code>entity_field</code>.</td></tr><tr><td><code>p_zscore</code></td><td>숫자</td><td>계산된 <code>zscore</code> 조회 기간 동안 엔터티 활동의 값입니다. 값이 클수록 <code>zscore</code> 더 비정상적임을 의미합니다.</td></tr><tr><td><code>p_mean</code></td><td>숫자</td><td>의 평균 값 <code>agg_field</code> 열의 이 엔터티에 대한 데이터 값이며, 조회 기간은 제외합니다. <code>subquery</code>.</td></tr><tr><td><code>p_stddev</code></td><td>숫자</td><td>의 표준 편차 <code>agg_field</code> 열의 이 엔터티에 대한 데이터 값이며, 조회 기간은 제외합니다. <code>subquery</code>, 조회 기간은 제외합니다. 값이 클수록 <code>p_stddev</code> 엔터티의 활동이 전체적으로 덜 일관적이었음을 의미합니다.</td></tr></tbody></table>

### new\_unique\_values

다음 `new_unique_values` macro는 데이터 세트를 스캔하여 주어진 엔터티의 최근 조회 기간에 존재하는 선택한 열에서 새로운 값 집합을 반환합니다.

#### 입력 인수

다음 인수는 아래 표시된 순서대로 매크로에 제공해야 합니다.

<table><thead><tr><th width="182">이름</th><th width="121">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>subquery</code></td><td>문자열</td><td>이전에 정의한 CTE의 이름으로, 이상을 찾는 데 사용할 기본 데이터를 포함합니다.</td></tr><tr><td><code>entity_field</code></td><td>문자열</td><td>그룹화에 사용할 열의 이름이며, 일반적으로 사용자 이름, IP 주소 또는 ID입니다.</td></tr><tr><td><code>agg_field</code></td><td>문자열</td><td>새 값을 검색할 열의 이름입니다.</td></tr><tr><td><code>interval</code></td><td>문자열</td><td>새 값을 찾을 기간의 크기입니다. 다음과 동일한 구문을 사용합니다 <a href="/pages/c0267a3023137cd43b5aa7a3df7665a839efbd78#time-offset-from-present-p_occurs_since">p_occurs_since</a>.</td></tr></tbody></table>

#### 반환

매크로 실행 후 반환되는 테이블에는 다음 열이 포함됩니다:

<table><thead><tr><th width="202">이름</th><th width="131">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>&#x3C;entity_field></code></td><td>임의의</td><td>정의된 <code>entity_field</code> 열.</td></tr><tr><td><code>&#x3C;agg_field></code></td><td>임의의</td><td>조회 기간 동안 <code>agg_field</code> 열에서 발견된 새로운 값</td></tr></tbody></table>

### statistical\_anomaly\_peer

이 매크로를 사용해 엔터티를 동일한 [동료 그룹](#peer-group-analysis)의 다른 항목들과 비교했을 때 비정상적인 수치 행동을 판별합니다. 예를 들어, 같은 태그를 가진 다른 EC2 인스턴스와 비교한 트래픽 볼륨이나, 같은 버킷의 다른 객체와 비교한 S3 객체에 대한 액세스 요청을 확인할 수 있습니다.

#### 입력 인수

다음 인수는 아래 표시된 순서대로 매크로에 제공해야 합니다.

<table><thead><tr><th width="174">이름</th><th width="105">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>subquery</code></td><td>문자열</td><td>이전에 정의한 CTE의 이름으로, 매크로가 분석할 데이터를 제공합니다.</td></tr><tr><td><code>entity_field</code></td><td>문자열</td><td>엔터티를 식별하는 데 사용할 열의 이름이며, 일반적으로 이름, IP 주소 또는 ID입니다.</td></tr><tr><td><code>group_field</code></td><td>문자열</td><td>엔터티를 그룹화하는 데 사용할 열의 이름입니다. 예를 들어 역할 이름 또는 계정 ID입니다.</td></tr><tr><td><code>agg_field</code></td><td>문자열</td><td>이상치를 검색할 열의 이름입니다.</td></tr><tr><td><code>agg_func</code></td><td>문자열</td><td>시간 기간 내 데이터 집계에 사용할 SQL 함수는 무엇입니까? <code>agg_field</code> 일반적인 값은 <code>count</code>, <code>sum</code>, 및 <code>max</code>.</td></tr><tr><td><code>tmag</code></td><td>문자열</td><td>이상을 찾을 조회 범위의 단위 수입니다. 즉, <strong>1</strong> in "<strong>1</strong> day"의</td></tr><tr><td><code>tunit</code></td><td>문자열</td><td>이상을 찾을 조회 범위의 시간 단위입니다. 즉, <strong>day</strong> "1 <strong>day</strong>"에서. 단수형이어야 합니다(끝에 "s" 없음).</td></tr><tr><td><code>zscore</code></td><td>숫자</td><td>이상치 임계값; 계산된 <code>zscore</code> 값이 이 값보다 높지 않으면 결과가 반환되지 않습니다.</td></tr></tbody></table>

#### 반환

매크로 실행 후 반환되는 테이블에는 다음 열이 포함됩니다:

<table><thead><tr><th width="194">이름</th><th width="131">데이터 유형</th><th width="424">설명</th></tr></thead><tbody><tr><td><code>N</code></td><td>숫자</td><td>의 데이터 값으로, <code>agg_field</code>에 의해 집계된 <code>agg_func</code>이며, 주어진 엔터티의 조회 기간 동안의 값입니다.</td></tr><tr><td><code>t1</code></td><td>타임스탬프</td><td>조회 기간의 시작.</td></tr><tr><td><code>t2</code></td><td>타임스탬프</td><td>조회 기간의 끝.</td></tr><tr><td><code>&#x3C;entity_field></code></td><td>임의의</td><td>선택한 <code>entity_field</code>.</td></tr><tr><td><code>&#x3C;group_field></code></td><td>임의의</td><td>선택한 <code>group_field</code>.</td></tr><tr><td><code>p_zscore</code></td><td>숫자</td><td>계산된 <code>zscore</code> 조회 기간 동안 엔터티 활동의 값입니다. 값이 클수록 <code>zscore</code> 더 비정상적임을 의미합니다.</td></tr><tr><td><code>p_mean</code></td><td>숫자</td><td>의 평균 값 <code>agg_field</code> 열의 이 엔터티에 대한 데이터 값이며, 조회 기간은 제외합니다. <code>subquery</code>.</td></tr><tr><td><code>p_stddev</code></td><td>숫자</td><td>의 표준 편차 <code>agg_field</code> 열의 이 엔터티에 대한 데이터 값이며, 조회 기간은 제외합니다. <code>subquery</code>, 조회 기간은 제외합니다. 값이 클수록 <code>p_stddev</code> 엔터티의 활동이 전체적으로 덜 일관적이었음을 의미합니다.</td></tr></tbody></table>

### new\_unique\_values\_peer

이 매크로를 사용해 엔터티가 이전에 그 [동료 그룹](#peer-group-analysis).

#### 입력 인수

다음 인수는 아래 표시된 순서대로 매크로에 제공해야 합니다.

<table><thead><tr><th width="182">이름</th><th width="121">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>subquery</code></td><td>문자열</td><td>이전에 정의한 CTE의 이름으로, 이상을 찾는 데 사용할 기본 데이터를 포함합니다.</td></tr><tr><td><code>entity_field</code></td><td>문자열</td><td>엔터티를 식별하는 데 사용할 열의 이름이며, 일반적으로 이름, IP 주소 또는 ID입니다.</td></tr><tr><td><code>group_field</code></td><td>문자열</td><td>엔터티를 그룹화하는 데 사용할 열의 이름입니다. 예를 들어 역할 이름 또는 계정 ID입니다.</td></tr><tr><td><code>agg_field</code></td><td>문자열</td><td>새 값을 검색할 열의 이름입니다.</td></tr><tr><td><code>interval</code></td><td>문자열</td><td>에서 팀 구성원에게 관찰되지 않았던 일을 했는지 식별합니다. 새 값을 찾을 조회 기간의 크기입니다. 다음과 동일한 구문을 사용합니다 <a href="/pages/c0267a3023137cd43b5aa7a3df7665a839efbd78#time-offset-from-present-p_occurs_since">p_occurs_since</a>.</td></tr></tbody></table>

#### 반환

매크로 실행 후 반환되는 테이블에는 다음 열이 포함됩니다:

<table><thead><tr><th width="202">이름</th><th width="131">데이터 유형</th><th>설명</th></tr></thead><tbody><tr><td><code>&#x3C;entity_field></code></td><td>임의의</td><td>정의된 <code>entity_field</code> 열.</td></tr><tr><td><code>&#x3C;group_field></code></td><td>임의의</td><td>정의된 <code>group_field</code> 열.</td></tr><tr><td><code>&#x3C;agg_field></code></td><td>임의의</td><td>조회 기간 동안 <code>agg_field</code> 열에서 발견된 새로운 값</td></tr></tbody></table>


---

# 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/search/scheduled-searches/templated-searches/anomaly-detection-macros.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.
