# 행동 분석 및 이상 탐지 템플릿 매크로

## 개요

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), 다음 방법으로 얻을 수 있습니다:

* Console 워크플로에서: 다음을 통해 `PantherManaged.Anomalies` [디택션 팩](/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="Console 워크플로" %}
Panther Console에서 매크로를 활성화하려면 다음을 활성화하세요 `PantherManaged.Anomalies` 팩:

1. Panther Console의 왼쪽 탐색 표시줄에서 **디택션**, 그런 다음 **Packs**.
2. 에서 **텍스트로 팩 필터링** 필드에 "Anomaly."를 입력합니다.
3. 오른쪽의 **Panther Anomaly 디택션 Pack** 타일에서 Enabled 토글을 다음으로 설정합니다 `ON`.

<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 워크플로" %}
매크로는 다음을 통해 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 콘텐츠 리포지토리에 가져오려면 다음 중 하나를 수행하세요:

* 리포지토리를 아무 panther-analysis와 동기화하세요 [릴리스](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가 관리하는 행동 분석 및 이상 징후 디택션 매크로를 다음에서 호출할 수 있습니다 [Data Explorer](/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의 왼쪽 탐색 표시줄에서 **조사** > **Data Explorer**.
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, 또는 new_unique_values_peer> %}
-- 네 개 모두가 아니라 매크로 하나만 지정하세요
```

5. 다음을 사용하여 서브쿼리를 정의합니다 [공통 테이블 식(Common Table Expression, CTE)](https://docs.snowflake.com/en/user-guide/queries-cte). 서브쿼리는 다음을 충족해야 합니다:
   * `SELECT` 최소한:
     * `p_event_time`
     * 엔터티 열. 엔터티는 흔히 일종의 ID(예: 이메일 주소, 사용자 ID, 애플리케이션 ID 또는 호스트 이름)이지만, 어떤 데이터 유형(예: IP 주소)도 될 수 있습니다. 이 열은 최상위 필드여야 합니다. 필드가 객체 또는 배열 안에 중첩되어 있다면 다음을 사용하여 열의 별칭을 만드세요 `AS` 키워드.
     * 집계 열. 다음의 경우 `statistical_anomaly` 쿼리에서는 이 열의 내용이 집계되고 비정상 값을 찾기 위해 스캔됩니다. 다음의 경우 `new_unique_values` 쿼리에서는 이 열의 내용이 새 값을 찾기 위해 스캔됩니다. 엔터티 열과 마찬가지로 이 열도 최상위 필드여야 합니다.
     * (다음을 사용하는 경우 `statistical_anomaly_peer` 또는 `new_unique_values_peer`) A [피어 그룹](#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, 또는 new_unique_values_peer>
(<subquery>, '<entity_col>', ...) }}
```

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

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

### 애드혹 검색을 넘어서

Panther의 행동 분석 및 이상 징후 디택션 쿼리는 위협 헌팅에 유용하지만, 모니터링 시스템으로 사용할 때 더 강력합니다. 쿼리는 다음과 같이 할 수 있습니다 [저장](/ko/search/scheduled-searches.md), 실행 일정을 설정하고 Scheduled Rules에 연결할 수 있습니다. 이렇게 하면 비정상 활동이 관찰될 때마다 경고를 받을 수 있습니다.

### **전체 예시**

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

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

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

```sql
-- pragma: template

{% import 'anomalies' statistical_anomaly %}
WITH subquery AS (
  -- 아웃바운드 요청 찾기:
  SELECT
    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
        logs
        조인
        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
        logs
        조인
        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)
   * 다음으로 이동됩니다 [Data Explorer](/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` Run Panther AI `new_unique_values` 이러한 분석을 수행하기 위해서입니다. 피어 버전에서는 기준선 통계가 피어 그룹에 따라 계산되고, 이후 엔터티 동작이 그 기준선과 비교됩니다.

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

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

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

### statistical\_anomaly

the `statistical_anomaly` 매크로는 최근 기간 내의 비정상 데이터 포인트를 찾기 위해 데이터 세트를 살펴봅니다. CTE를 기본 데이터 세트로 사용하고, 해당 기간 동안 한 엔터티의 기준선 활동을 동일 엔터티의 최신 활동과 비교하여 이 동작이 얼마나 비정상적인지 계산합니다.

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

#### 입력 인수

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

<table><thead><tr><th width="174">Name</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>일</strong> "1 <strong>일</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">Name</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

the `new_unique_values` 매크로는 데이터 세트를 스캔하고, 주어진 엔터티에 대한 최근 조회 기간 동안 선택한 열에서 새로운 값 집합을 반환합니다.

#### 입력 인수

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

<table><thead><tr><th width="182">Name</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>간격</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">Name</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">Name</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>일</strong> "1 <strong>일</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">Name</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">Name</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>간격</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">Name</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: 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/search/scheduled-searches/templated-searches/anomaly-detection-macros.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.
