

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Amazon SES API를 사용하여 사용 통계 모니터링
<a name="monitor-sending-activity-api"></a>

Amazon SES API는 서비스 사용에 대한 정보를 반환하는 `GetSendStatistics` 작업을 제공합니다. 따라서 필요할 때는 조정할 수 있도록 전송 통계를 정기적으로 확인하는 것이 바람직합니다.

`GetSendStatistics` 작업을 호출하면 지난 2주 동안의 전송 활동을 나타내는 데이터 요소 목록이 전송됩니다. 이 목록의 각 데이터 요소는 15분 단위의 활동을 나타내며 해당 기간에 대한 다음과 같은 정보를 포함합니다.
+ 하드 바운스 수
+ 불만 제기 수
+ 전송 완료 시도 수(전송한 이메일 수와 일치함)
+ 거부된 전송 시도 수
+ 분석 기간을 나타내는 타임스탬프

`GetSendStatistics` 작업에 대한 자세한 설명은 [Amazon Simple Email Service API 참조](https://docs.aws.amazon.com/ses/latest/APIReference/GetSendStatistics.html)를 참조하십시오.

이 단원에는 다음과 같은 주제가 포함되어 있습니다.
+ [를 사용하여 `GetSendStatistics` API 작업 호출 AWS CLI](#monitor-sending-activity-api-cli)
+ [프로그래밍 방식의 `GetSendStatistics` 작업 호출](#monitor-sending-activity-api-sdk)

## 를 사용하여 `GetSendStatistics` API 작업 호출 AWS CLI
<a name="monitor-sending-activity-api-cli"></a>

`GetSendStatistics` API 작업을 가장 쉽게 호출하려면 [AWS Command Line Interface](https://aws.amazon.com/cli)(AWS CLI)를 사용해야 합니다.

**를 사용하여 `GetSendStatistics` API 작업을 호출하려면 AWS CLI**

1.  AWS CLI를 아직 설치하지 않았다면 설치합니다. 자세한 내용은 *AWS Command Line Interface 사용 설명서*의 "[설치" AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)를 참조하세요.

1. 아직 구성하지 않은 경우 자격 증명을 사용하도록 AWS CLI AWS 를 구성합니다. 자세한 내용은 *AWS Command Line Interface 사용 설명서*의 "[Configuring the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)"를 참조하세요.

1. 명령줄 프롬프트에서 다음 명령을 실행합니다.

   ```
   aws ses get-send-statistics
   ```

    AWS CLI 가 제대로 구성된 경우 전송 통계 목록이 JSON 형식으로 표시됩니다. JSON 객체에는 각각 15분 동안 수집된 전송 통계가 포함됩니다.

## 프로그래밍 방식의 `GetSendStatistics` 작업 호출
<a name="monitor-sending-activity-api-sdk"></a>

SDK를 사용하여 `GetSendStatistics` 작업을 호출할 수도 있습니다. AWS SDKs 이 섹션에는 Go, PHP, Python 및 Ruby용 AWS SDKs 대한 코드 예제가 포함되어 있습니다. 다음 링크 중 하나를 선택하면 해당 언어의 코드 예제를 볼 수 있습니다.
+ [AWS SDK for Go코드 예제](#code-example-getsendstatistics-golang)
+ [AWS SDK for PHP코드 예제](#code-example-getsendstatistics-php)
+ [AWS SDK for Python (Boto)코드 예제](#code-example-getsendstatistics-python)
+ [AWS SDK for Ruby코드 예제](#code-example-getsendstatistics-ruby)

**참고**  
이 코드 예제에서는 액세스 키 ID, AWS 보안 AWS 액세스 키 및 선호하는 AWS 리전이 포함된 AWS 공유 자격 증명 파일을 생성했다고 가정합니다. 자세한 내용은 [공유 자격 증명 및 구성 파일](https://docs.aws.amazon.com/credref/latest/refdocs/creds-config-files.html)을 참조하십시오.

### 를 `GetSendStatistics` 사용하여 호출 AWS SDK for Go
<a name="code-example-getsendstatistics-golang"></a>

```
 1. package main
 2.     
 3. import (
 4.     "fmt"
 5.     
 6.     //go get github.com/aws/aws-sdk-go/...
 7.     "github.com/aws/aws-sdk-go/aws"
 8.     "github.com/aws/aws-sdk-go/aws/session"
 9.     "github.com/aws/aws-sdk-go/service/ses"
10.     "github.com/aws/aws-sdk-go/aws/awserr"
11. )
12.     
13. const (
14.     // Replace us-west-2 with the AWS Region you're using for Amazon SES.
15.     AwsRegion = "us-west-2"
16. )
17.     
18. func main() {
19.     
20.     // Create a new session and specify an AWS Region.
21.     sess, err := session.NewSession(&aws.Config{
22.         Region:aws.String(AwsRegion)},
23.     )
24.     
25.     // Create an SES client in the session.
26.     svc := ses.New(sess)
27.     input := &ses.GetSendStatisticsInput{}
28.     
29.     result, err := svc.GetSendStatistics(input)
30.     
31.     // Display error messages if they occur.
32.     if err != nil {
33.         if aerr, ok := err.(awserr.Error); ok {
34.             switch aerr.Code() {
35.             default:
36.                 fmt.Println(aerr.Error())
37.             }
38.         } else {
39.             // Print the error, cast err to awserr.Error to get the Code and
40.             // Message from an error.
41.             fmt.Println(err.Error())
42.         }
43.         return
44.     }
45.     
46.     fmt.Println(result)
47. }
```

### 를 `GetSendStatistics` 사용하여 호출 AWS SDK for PHP
<a name="code-example-getsendstatistics-php"></a>

```
 1. <?php
 2. 
 3. // Replace path_to_sdk_inclusion with the path to the SDK as described in 
 4. // http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html
 5. define('REQUIRED_FILE','path_to_sdk_inclusion');
 6.                                                   
 7. // Replace us-west-2 with the AWS Region you're using for Amazon SES.
 8. define('REGION','us-west-2'); 
 9. 
10. require REQUIRED_FILE;
11. 
12. use Aws\Ses\SesClient;
13. 
14. $client = SesClient::factory(array(
15.     'version'=> 'latest',     
16.     'region' => REGION
17. ));
18. 
19. try {
20.      $result = $client->getSendStatistics([]);
21. 	 echo($result);
22. } catch (Exception $e) {
23.      echo($e->getMessage()."\n");
24. }
25. 
26. ?>
```

### 를 `GetSendStatistics` 사용하여 호출 AWS SDK for Python (Boto)
<a name="code-example-getsendstatistics-python"></a>

```
 1. import boto3 #pip install boto3
 2. import json
 3. from botocore.exceptions import ClientError
 4. 
 5. client = boto3.client('ses')
 6. 
 7. try:
 8.     response = client.get_send_statistics(
 9. )
10. except ClientError as e:
11.     print(e.response['Error']['Message'])
12. else:
13.     print(json.dumps(response, indent=4, sort_keys=True, default=str))
```

### 를 `GetSendStatistics` 사용하여 호출 AWS SDK for Ruby
<a name="code-example-getsendstatistics-ruby"></a>

```
 1. require 'aws-sdk' # gem install aws-sdk
 2. require 'json'
 3. 
 4. # Replace us-west-2 with the AWS Region you're using for Amazon SES.
 5. awsregion = "us-west-2"
 6. 
 7. # Create a new SES resource and specify a region
 8. ses = Aws::SES::Client.new(region: awsregion)
 9. 
10. begin
11. 
12.   resp = ses.get_send_statistics({
13.   })
14.   puts JSON.pretty_generate(resp.to_h)
15. 
16. # If something goes wrong, display an error message.
17. rescue Aws::SES::Errors::ServiceError => error
18.   puts error
19. 
20. end
```