翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Amazon SES API を使用した使用統計のモニタリング
Amazon SES API は、 GetSendStatistics オペレーションを使用してサービスの使用に関する情報を返します。送信統計を定期的にチェックし、必要に応じて調整を行うようお勧めします。
GetSendStatistics オペレーションを呼び出すと、過去 2 週間の送信アクティビティを示すデータポイントのリストが返されます。このリストの各データポイントは、15 分間のアクティビティを示し、その期間に関する以下の情報が含まれています:
-
ハードバウンス数
-
苦情数
-
配信試行回数 (送信した E メールの数に相当します)
-
送信試行の拒否数
-
分析期間のタイムスタンプ
GetSendStatistics オペレーションの詳細については、Amazon Simple Email Service API リファレンスを参照してください。
このセクションでは、以下のトピックについて説明します。
を使用して GetSendStatistics API オペレーションを呼び出す AWS CLI
GetSendStatistics API オペレーションを最も簡単に呼び出す方法は AWS Command Line Interface
を使用して GetSendStatistics API オペレーションを呼び出すには AWS CLI
-
AWS CLIをインストールします (まだの場合)。詳細については、 AWS Command Line Interface ユーザーガイドの「 のインストール AWS Command Line Interface」を参照してください。
-
まだ設定していない場合は、認証情報 AWS を使用する AWS CLI ように を設定します。詳細については、 AWS Command Line Interface ユーザーガイドの「 の設定 AWS CLI」を参照してください。
-
コマンドラインから、以下のコマンドを実行します。
aws ses get-send-statisticsAWS CLI が適切に設定されている場合、JSON 形式の送信統計のリストが表示されます。JSON オブジェクトごとに 15 分間の集約された送信統計が含まれています。
プログラムを使用した GetSendStatistics オペレーションの呼び出し
AWS SDKs を使用して GetSendStatisticsオペレーションを呼び出すこともできます。このセクションでは、Go、PHP、Python、Ruby 用の AWS SDKs のコード例を示します。以下のいずれかのリンクを選択すると、その言語でコード例が表示されます。
注記
これらのコード例は、 AWS アクセスキー ID、 AWS シークレットアクセスキー、および任意の AWS リージョンを含む AWS 共有認証情報ファイルを作成していることを前提としています。詳細については、「共有認証情報ファイルと設定ファイル」を参照してください。
GetSendStatistics を使用した の呼び出し AWS SDK for Go
package main import ( "fmt" //go get github.com/aws/aws-sdk-go/... "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" "github.com/aws/aws-sdk-go/aws/awserr" ) const ( // Replace us-west-2 with the AWS Region you're using for Amazon SES. AwsRegion = "us-west-2" ) func main() { // Create a new session and specify an AWS Region. sess, err := session.NewSession(&aws.Config{ Region:aws.String(AwsRegion)}, ) // Create an SES client in the session. svc := ses.New(sess) input := &ses.GetSendStatisticsInput{} result, err := svc.GetSendStatistics(input) // Display error messages if they occur. if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) }
GetSendStatistics を使用した の呼び出し AWS SDK for PHP
<?php // Replace path_to_sdk_inclusion with the path to the SDK as described in // http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html define('REQUIRED_FILE','path_to_sdk_inclusion'); // Replace us-west-2 with the AWS Region you're using for Amazon SES. define('REGION','us-west-2'); require REQUIRED_FILE; use Aws\Ses\SesClient; $client = SesClient::factory(array( 'version'=> 'latest', 'region' => REGION )); try { $result = $client->getSendStatistics([]); echo($result); } catch (Exception $e) { echo($e->getMessage()."\n"); } ?>
GetSendStatistics を使用した の呼び出し AWS SDK for Python (Boto)
import boto3 #pip install boto3 import json from botocore.exceptions import ClientError client = boto3.client('ses') try: response = client.get_send_statistics( ) except ClientError as e: print(e.response['Error']['Message']) else: print(json.dumps(response, indent=4, sort_keys=True, default=str))
GetSendStatistics を使用して を呼び出す AWS SDK for Ruby
require 'aws-sdk' # gem install aws-sdk require 'json' # Replace us-west-2 with the AWS Region you're using for Amazon SES. awsregion = "us-west-2" # Create a new SES resource and specify a region ses = Aws::SES::Client.new(region: awsregion) begin resp = ses.get_send_statistics({ }) puts JSON.pretty_generate(resp.to_h) # If something goes wrong, display an error message. rescue Aws::SES::Errors::ServiceError => error puts error end