# 로그 소스 관리

## 개요

Panther API는 다음 로그 소스 작업을 지원합니다:

* 로그 소스 통합 목록 조회
* 특정 로그 소스 통합의 세부 정보 가져오기
* 로그 소스 통합 삭제
* (S3 소스에만 해당) 새 로그 소스 통합 생성
* (S3 소스에만 해당) 기존 로그 소스 통합 업데이트

{% hint style="info" %}
사용자를 사용할 것이며, `ListSources`, `GetSource`및 `DeleteSource` 작업은 Panther의 모든 로그 소스에 대해 지원됩니다. 생성 및 업데이트 작업(`CreateS3LogSource` 와 `UpdateS3LogSource`)는 현재 S3 로그 소스로만 제한됩니다.
{% endhint %}

콘솔의 API 플레이그라운드 또는 GraphQL-over-HTTP API를 사용하여 Panther의 API를 호출할 수 있습니다. 이러한 방법에 대한 자세한 내용은 [Panther API](https://docs.panther.com/ko/panther/api/..#step-1-choose-a-method-for-invoking-the-api).

### 필수 API 토큰 권한

API 호출을 시작하기 전에 API 토큰에 필요한 권한이 연결되어 있는지 확인하세요:

* **로그 소스 보기**: 모든 로그 소스 관리 작업에 필요합니다.
* **로그 소스 관리(Manage Log Sources)**: 변경을 수반하는 로그 소스 관리 작업(즉, `CreateS3LogSource`, `UpdateS3LogSource`및 `DeleteSource`).
* **사용자 정보 조회(Read User Info)**: 생성자(createdBy)와 같은 액터와 관련된 통합 필드를 검색하려는 경우 필요합니다. `createdBy`.

<figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-4692296563f124328e000bab991e05d423db5e2b%2FScreenshot%202023-06-12%20at%203.45.48%20PM.png?alt=media" alt="An &#x22;Integrations&#x22; header is above four checkboxes: View Cloud Security Sources, Manage Cloud Security Sources, View Log Sources, and Manage Log Sources." width="563"><figcaption></figcaption></figure>

## 일반적인 로그 소스 작업

아래는 Panther의 가장 일반적인 GraphQL 로그 소스 작업 예시입니다. 이 예시들은 GraphQL 클라이언트(또는 `curl`)을 사용하여 Panther의 GraphQL API를 호출하기 위해 전송해야 하는 문서를 보여줍니다.

#### 로그 소스 목록 조회

{% hint style="info" %}
현재는 페이징이 `소스에서 지원되지 않습니다`—모든 로그 소스가 결과의 첫 페이지에 반환됩니다. 아래의 `cursor` 필드를 `input` 객체는 페이징이 향후에 지원될 때를 위한 자리표시자입니다.
{% endhint %}

```graphql
query ListSources {
  sources(input: { cursor: "" }) {
    edges {
      node {
        createdAtTime
        createdBy {
          ... on User {
            id
          }
          ... on APIToken {
            id
          }
        }
        integrationId
        integrationLabel
        integrationType
        isEditable
        isHealthy
        lastEventProcessedAtTime
        lastEventReceivedAtTime
        lastModified
        logTypes
      }
    }
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
  }
}
```

#### 로그 소스 조회

다음에 대한 입력은 `source` 가져오려는 로그 소스의 ID입니다.

```graphql
query GetSource {
  source(id: "bcd45662-bab7-4f99-b69f-083a0212568d") {
    createdAtTime
    createdBy {
      ... on User {
        id
      }
      ... on APIToken {
        id
      }
    }
    integrationId
    integrationLabel
    integrationType
    isEditable
    isHealthy
    lastEventProcessedAtTime
    lastEventReceivedAtTime
    lastModified
    logTypes
  }
}
```

#### 로그 소스 삭제

다음에 대한 입력은 `deleteSource` 삭제하려는 로그 소스의 ID입니다.

```graphql
mutation DeleteSource {
  deleteSource(input: { id: "bcd45662-bab7-4f99-b69f-083a0212568d" }) {
    id
  }
}
```

#### S3 로그 소스 생성

{% hint style="info" %}
S3 로그 소스를 생성하는 것도 가능합니다 [Terraform을 사용하여](https://docs.panther.com/ko/panther/terraform/s3), 또는 [Panther 콘솔에서 수동으로](https://docs.panther.com/ko/data-onboarding/data-transports/aws/s3).
{% endhint %}

{% hint style="warning" %}
Panther에서 처음 생성하는 로그 소스는 Panther 콘솔에서 수행되어야 합니다. API를 사용해 첫 Panther 로그 소스를 설정하면 [이 지식 베이스 문서를 참조하세요](https://help.panther.com/articles/2327494518-why-is-my-sns-topic-stuck-in-a-pending-confirmation-state-for-the-sqs-confirmation-for-panther).
{% endhint %}

아래 예시 요청에서, `input` 는 S3 로그 소스를 완전히 나타내는 객체입니다. 표시된 모든 필드는 필수입니다.

에 `logProcessingRole` 은 IAM 역할의 ARN입니다. 이 역할을 생성할 때에는 [다음 지침](https://docs.panther.com/ko/data-onboarding/data-transports/aws/s3#i-want-to-set-everything-up-on-my-own)을 참고하세요. 어떤 정책이 연결되어야 하는지 설명합니다.

```graphql
mutation CreateS3LogSource {
  createS3Source(
    input: {
      awsAccountId: "0123456789012"
      label: "My Log Source"
      logProcessingRole: "arn:aws:iam::0123456789012:role/PantherLogProcessingRole-somerole"
      logStreamType: JSON
      managedBucketNotifications: false
      s3Bucket: "name-of-my-bucket"
      s3PrefixLogTypes: [
        { excludedPrefixes: [], logTypes: ["AWS.ALB"], prefix: "" }
      ]
    }
  ) {
    logSource {
      createdAtTime
      integrationId
      integrationLabel
      integrationType
      isEditable
      isHealthy
      lastEventProcessedAtTime
      lastEventReceivedAtTime
      lastModified
      logTypes
    }
  }
}
```

#### S3 로그 소스 업데이트

아래 예시 요청에서, `input` 는 업데이트된 S3 로그 소스를 완전히 나타내는 객체입니다. 표시된 모든 필드는 필수입니다. 왜냐하면 `updateS3Source` 는 기존 로그 소스의 모든 필드를 교체(특정 필드만 업데이트하지 않음)합니다.

```graphql
mutation UpdateS3LogSource {
  updateS3Source(
    input: {
      id: "bcd45662-bab7-4f99-b69f-083a0212568d"
      label: "My Log Source2"
      kmsKey: ""
      logProcessingRole: "arn:aws:iam::0123456789012:role/PantherLogProcessingRole-somerole"
      logStreamType: JSON
      managedBucketNotifications: false
      s3PrefixLogTypes: [
        { excludedPrefixes: [], logTypes: ["AWS.ALB"], prefix: "" }
      ]
    }
  ) {
    logSource {
      createdAtTime
      integrationId
      integrationLabel
      integrationType
      isEditable
      isHealthy
      lastEventProcessedAtTime
      lastEventReceivedAtTime
      lastModified
      logTypes
    }
  }
}
```
