# 메트릭

## 개요

Panther API는 다음 사용자 메트릭 작업을 제공합니다:

* Panther가 특정 기간 동안 수집 및/또는 처리한 총 바이트 수와 이벤트 수
* 특정 기간 동안 각 심각도 유형별로 생성된 알림의 세부 내역\\

Console의 API Playground 또는 GraphQL-over-HTTP API를 사용하여 Panther의 API를 호출할 수 있습니다. 이러한 방법에 대해 자세히 알아보려면 다음을 참조하세요. [Panther API](/ko/panther/api.md#step-1-choose-a-method-for-invoking-the-api).

핵심 메트릭 작업에 대한 GraphQL 쿼리, 변형, 그리고 엔드투엔드 워크플로 예시는 아래 섹션을 참조하세요.

### `totalBytesIngested` 대 `totalBytesProcessed`

다음 `totalBytesIngested` 및 `totalBytesProcessed` 메트릭은 비슷하게 들리지만, 다음과 같은 차이가 있습니다:

* `totalBytesIngested`: Panther가 지난 1년(현재 날짜로부터 최근 365일) 동안 수집한 총 바이트 수입니다.
* `totalBytesProcessed`: Panther가 쿼리에서 정의한 특정 기간 내에 수집한 총 바이트 수입니다.

## 일반적인 메트릭 작업

아래는 Panther에서 가장 일반적인 GraphQL 메트릭 작업 중 일부입니다. 이 예시는 GraphQL 클라이언트(또는 `curl`)를 사용하여 Panther의 GraphQL API를 호출할 때 보내야 하는 문서를 보여줍니다.

**메트릭 쿼리**

```graphql
# `GetMetrics`는 작업의 별칭입니다. 관심 없는 
# 필드/정보는 생략하고 원하는 것만 쿼리할 수 있습니다
query GetMetrics {
  metrics(input: { 
    fromDate: "2021-01-01T00:00:00Z"
    toDate: "2021-12-31T23:59:59Z"
  }) {
    alertsPerSeverity {
      label
      값
      breakdown
    }
    alertsPerRule {
      label
      값
      entityId
    }
    eventsProcessedPerLogType {
      label
      값
      breakdown
    }
    bytesProcessedPerSource {
      label
      값
      breakdown
    }
    latencyPerLogType {
      label
      값
    }
    bytesIngestedPerSource {
      label
      값
    }
    bytesQueriedPerSource {
      label
      값
      breakdown
    }
    totalAlerts
    totalBytesIngested
    totalBytesProcessed
    totalBytesQueried
    totalEventsProcessed
  }
}
```

{% hint style="info" %}
다음 `breakdown` 필드는 X축으로 시간을 사용하는 차트에만 유용합니다. 이 필드는 타임스탬프 -> 값의 맵을 해당 `값` 필드의 구성 요소에 대한 "세부 내역"으로 생성합니다.
{% endhint %}

### 엔드투엔드 예시

아래에서는 [일반 작업](#common-metrics-operations) 예시의 작업을 바탕으로 엔드투엔드 사용 사례 흐름을 보여줍니다.

#### **Panther의 로그 메트릭 가져오기**

{% tabs %}
{% tab title="Python" %}

```python
# pip install gql aiohttp

from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

transport = AIOHTTPTransport(
  url="YOUR_PANTHER_API_URL",
  headers={"X-API-Key": "YOUR_API_KEY"},
)

client = Client(transport=transport, fetch_schema_from_transport=True)

get_metrics = gql(
  """
  query GetMetrics($input: MetricsInput!)  {
    metrics(input: $input) {
      totalAlerts
      totalEventsProcessed
    }
  }
  """
)

data = client.execute(
  get_metrics,
  variable_values= {
    "input": {
      "fromDate": "2022-07-01T00:00:00Z",
      "toDate": "2022-07-31T23:59:59Z",
    }
  }
)

print(f'7월에 Panther는 {data["metrics"]["totalEventsProcessed"]}개의 이벤트를 처리하고 {data["metrics"]["totalAlerts"]}개의 알림을 생성했습니다')
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import { GraphQLClient, gql } from "graphql-request";

const client = new GraphQLClient(
  "YOUR_PANTHER_API_URL",
  { headers: { "X-API-Key": "YOUR_API_KEY" } }
);



const getMetrics = gql`
  query GetMetrics($input: MetricsInput!)  {
    metrics(input: $input) {
      totalAlerts
      totalEventsProcessed
    }
  }
`;

(async () => {
  try {
    const data = await client.request(getMetrics, {
      input: {
        fromDate: "2022-07-01T00:00:00Z",
        toDate: "2022-07-31T23:59:59Z"
      }
    });

    console.log(
      `7월에 Panther는 ${data.metrics.totalEventsProcessed}개의 이벤트를 처리하고 ${data.metrics.totalAlerts}개의 알림을 생성했습니다.`
    );
  } catch (err) {
    console.error(err);
  }
})();

```

{% endtab %}
{% endtabs %}


---

# 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/panther/api/graphql/metrics.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.
