# 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) 또는 [Data Explorer](/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 '디택션 deleted!'
   ```

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

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

1단계에서 디택션을 정의하고 **새로 추가** 아래 **Test** 테스트를 시작하기 위해.

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

1. 별도의 브라우저 탭에서 Panther Console을 엽니다. 테스트 감사 로그를 생성하기 위해 디택션을 작성한 작업을 수행합니다.
   * 위의 예시에서는 Panther Console에서 디택션을 삭제하는 작업을 확인하기 위한 디택션을 정의했습니다. 이 예시에서는 다음 단계를 따릅니다:
     1. 다음으로 이동합니다 **Build > 디택션**.
     2. 테스트 디택션을 생성합니다.
     3. 디택션을 성공적으로 생성한 후 삭제합니다.
2. 왼쪽 사이드바에서 다음을 클릭합니다 **Investigate > Data Explorer**.
3. 테스트하는 작업에 대한 감사 로그를 찾기 위해 쿼리를 실행합니다.
   * 우리의 예시를 바탕으로, 최근에 삭제된 디택션을 확인하기 위해 다음 쿼리를 사용합니다:

     ```sql
     SELECT * FROM panther_logs.panther_audit WHERE actionName = 'DELETE_디택션'
     timestamp 기준 내림차순 정렬
     LIMIT 1;
     ```
   * 결과가 반환되지 않으면 몇 분 기다린 후 다시 시도하세요.
4. Data Explorer 결과에서 이 로그를 나타내는 JSON 개체를 복사합니다. 정의한 디택션으로 돌아간 다음 JSON 개체를 붙여넣습니다. **Test** 텍스트 편집기.
5. 떠나세요 **디택션은 예시 이벤트를 기반으로 트리거되어야 합니다** 토글이 다음으로 설정됨 `YES`.
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 '디택션 deleted!'
```

audit log에서 찾을 수 있는 값을 사용하여 더 설명적인 알러트 제목을 구성할 수 있습니다. `actionParams` 필드:

```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_디택션_id}' deleted by {actor_type} {actor_readable_id}!"
```

여기에서 [로그 스키마](/ko/data-onboarding/supported-logs/panther-audit-logs.md#schema) 감사 로그 필드에 대한 자세한 내용은.

{% hint style="info" %}
The `actionParams` 필드는 감사된 각 작업마다 다릅니다. 특정 작업에 대해 이 필드에 어떤 정보가 포함되어 있는지 이해하려면, [해당 작업의 감사 로그에 대해 데이터 레이크를 쿼리하고](#querying-the-data-lake-for-panther-audit-logs) 그 결과를 바탕으로 해당 작업에 대한 탐지 규칙을 작성하는 방법을 정하세요.
{% endhint %}


---

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