> 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/supported-logs/panther-audit-logs/querying-and-writing-detections-for-panther-audit-logs.md).

# Panther 감사 로그에 대한 디택션 쿼리 및 작성

## 개요

다음을 할 수 있습니다 [Panther 감사 로그를 Panther로 수집하도록 활성화](/ko/data-onboarding/supported-logs/panther-audit-logs.md#enabling-audit-logs-as-a-log-source), 즉 이후에는 디택션, 데이터 레이크 쿼리 등에서 Panther 감사 로그를 다룰 수 있습니다.

## Panther 감사 로그를 위한 데이터 레이크 쿼리

감사 로그는 데이터 레이크의 다음 위치에서 찾을 수 있습니다: `panther_logs.panther_audit`. 다음 쿼리는 [검색](/ko/search/search-tool.md) 또는 [데이터 탐색기](/ko/search/data-explorer.md)지난 하루 동안의 모든 감사 이벤트를 표시합니다:

```sql
SELECT * FROM panther_logs.panther_audit WHERE p_occurs_since('1 day');
```

이 쿼리의 결과에는 여러 감사 로그가 포함되며, 예시는 아래에서 볼 수 있습니다:

```json
{
	"XForwardedFor": [
		"72.72.72.72",
		"130.172.130.172"
	],
	"actionDescription": "사용 가능한 모든 데이터 레이크 데이터베이스의 세부 정보를 나열합니다",
	"actionName": "LIST_DATA_LAKE_DATABASES",
	"actionParams": {},
	"actionResult": "SUCCEEDED",
	"actor": {
		"attributes": {
			"email": "foo.user@acmecorp.io",
			"emailVerified": false,
			"roleId": ""
		},
		"id": "AcmecorpSSO_foo.user@acmecorp.io",
		"name": "foo.user@acmecorp.io",
		"type": "USER"
	},
	"errors": null,
	"p_any_ip_addresses": [
		"72.72.72.72",
		"130.172.130.172"
	],
	"p_any_trace_ids": [
		"AcmecorpSSO_foo.user@acmecorp.io"
	],
	"p_any_usernames": [
		"foo.user@acmecorp.io"
	],
	"p_event_time": "2022-04-22 15:39:55.358",
	"p_log_type": "Panther.Audit",
	"p_parse_time": "2022-04-22 15:41:36.276",
	"p_row_id": "asdfdjklasdfjklasdfjlk",
	"p_source_id": "abc12345-ab12-cd12-ef12-abc1234567890",
	"p_source_label": "panther-audit-logs-us-east-1",
	"pantherVersion": "1.34.0",
	"sourceIP": "72.72.72.72",
	"timestamp": "2022-04-22 15:39:55.358",
	"userAgent": ""
}
```

## Panther 감사 로그를 위한 디택션 작성

감사 로그를 활용하면 Panther 내에서 비정상적이거나 중요한 작업이 수행될 때 알림을 생성하는 강력한 디택션을 작성할 수 있습니다.

디택션이 삭제되었을 때 알림을 보내는 디택션을 작성해 봅시다.

### 1단계: 디택션 만들기 시작

1. Panther Console의 왼쪽 탐색 모음에서 **탐지**.
2. 디택션 페이지에서 클릭 **새로 만들기**.
3. 다음 **디택션 유형 선택** 모달에서 클릭 **룰**.
4. 설명적인 **이름**  이름, 예: `Panther 디택션 삭제됨`.
5. 아래 **다음 소스의 경우**에서 **로그 유형** 드롭다운에서 선택 `Panther.Audit`.\
   ![Under a "For the Following Source" header is a "Log Types" dropdown. A "Panther.Audit" selection has been made.](/files/d76e424089bd8f42a85b2a38c7af09734b72b54d)
6. 다음 **감지** 타일을 클릭하세요: **파이썬 편집기**.
7. 코드 편집기에서 다음 Python 코드를 입력하세요. 이 코드는 디택션이 삭제될 때 알러트를 생성합니다:

   ```python
   def 룰(event):    
       return event.get('actionName') == 'DELETE_디택션'
   def title(event):
       return '디택션 삭제됨!'
   ```

   * 이 코드는 다음을 사용해 간단한 제목을 정의합니다 [`제목()`](/ko/detections/rules/python.md#title) 함수. 아래에서 더 설명적인 제목을 만드는 방법을 알아보세요, in [설명적인 알러트 제목 만들기](#creating-a-descriptive-alert-title).
8. 다음 **알러트 생성** 타일, 아래 **필수 필드**, 선택하세요 **심각도**.
9. 다음까지 아래로 스크롤합니다 **테스트** 타일을 선택하고 클릭 **새로 추가**.
   * 에서 계속 [2단계: 디택션에 대한 테스트 만들기](#step-2-create-a-test-for-the-detection).

### 2단계: 디택션에 대한 테스트 만들기

1단계에서 디택션을 정의하고 클릭했습니다 **새로 추가** 아래에 **테스트** 테스트 프로세스를 시작하기 위해.

아래에서는 여러분이 디택션을 작성한 동작에 대한 테스트 데이터를 생성하게 됩니다. 예시에서는 Panther Console에서 디택션을 삭제하는 동작을 확인하기 위한 디택션을 정의했습니다.

1. 별도의 브라우저 탭에서 Panther Console을 엽니다. 테스트 감사 로그를 생성하려면 디택션을 작성한 동작을 수행하세요.
   * 위 예시에서는 Panther Console에서 디택션을 삭제하는 동작을 확인하기 위한 디택션을 정의했습니다. 이 예시에서는 다음 단계를 따르면 됩니다:
     1. 다음으로 이동합니다: **탐지**.
     2. 테스트 디택션을 생성하세요.
     3. 디택션을 성공적으로 생성한 후 삭제합니다.
2. 왼쪽 사이드바에서 클릭 **검색**, 그런 다음 다음을 선택합니다 **데이터 탐색기** 탭.
3. 테스트 중인 작업에 대한 감사 로그를 찾기 위해 쿼리를 실행하세요.
   * 예시를 바탕으로, 최근에 삭제된 디택션을 확인하기 위해 다음 쿼리를 사용합니다:

     ```sql
     SELECT * FROM panther_logs.panther_audit WHERE actionName = 'DELETE_디택션'
     timestamp를 내림차순으로 정렬
     LIMIT 1;
     ```
   * 결과가 반환되지 않으면 몇 분 기다린 후 다시 시도하세요.
4. 이 로그를 나타내는 Data Explorer 결과의 JSON 개체를 복사합니다. 정의한 디택션으로 돌아간 다음, JSON 개체를 다음에 붙여넣습니다 **테스트** 텍스트 편집기.
5. 그대로 둡니다. **디택션은 예제 이벤트를 기반으로 트리거되어야 합니다.** 토글을 다음으로 설정 `예`.
6. 클릭합니다 **테스트 실행**.
   * 디택션이 예상대로 실행되고 알러트 제목이 예상대로 표시되는지 확인합니다.\
     ![The image shows the test from a rule in the Panther Console. At the bottom under the "Mock Testing" section, there is a message that says "PASS" and includes the alert title and dedup string for the successful test.](/files/677d9c8806668eb240104815131446cafd48bcdb)
7. 페이지의 오른쪽 상단 모서리에서 클릭합니다. **배포.**

### 설명적인 알러트 제목 만들기

위의 예에서는 간단한 알러트 제목을 사용했습니다:

```python
def title(event):
    return '디택션 삭제됨!'
```

다음에 있는 값들을 사용하여 더 설명적인 알러트 제목을 구성할 수 있습니다 `동작 매개변수` 감사 로그 내의 필드:

```python
def title(event):
    deleted_디택션_id = event.get('actionParams').get('input').get('디택션s')[0].get('id')
    actor_type = event.get('actor').get('type').lower()
    actor_readable_id = event.get('actor').get('name') if event.get('actor').get('name') else event.get('actor').get('id')
    return f"디택션 '{deleted_detection_id}' {actor_type} {actor_readable_id}에 의해 삭제되었습니다!"
```

다음을 참조하세요 [로그 스키마](/ko/data-onboarding/supported-logs/panther-audit-logs.md#schema) 감사 로그 필드에 대한 자세한 정보는.

{% hint style="info" %}
다음 `동작 매개변수` 필드는 감사된 각 작업마다 다릅니다. 특정 작업에 대해 이 필드에 어떤 정보가 있는지 이해하려면, [주어진 작업에 대한 감사 로그를 데이터 레이크에서 조회하세요](#querying-the-data-lake-for-panther-audit-logs) 그리고 그 결과를 바탕으로 해당 작업에 대한 탐지를 작성하는 방법을 정하세요.
{% endhint %}


---

# 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/supported-logs/panther-audit-logs/querying-and-writing-detections-for-panther-audit-logs.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.
