

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Amazon VPC Lattice をモニタリングする
<a name="monitoring-overview"></a>

このセクションの機能を使用して、Amazon VPC Lattice サービスネットワーク、サービス、ターゲットグループ、VPC 接続をモニタリングします。

**Topics**
+ [Amazon VPC Lattice の CloudWatch メトリクス](monitoring-cloudwatch.md)
+ [Amazon VPC Lattice のアクセスログ](monitoring-access-logs.md)
+ [Amazon VPC Lattice の CloudTrail ログ](monitoring-cloudtrail.md)

# Amazon VPC Lattice の CloudWatch メトリクス
<a name="monitoring-cloudwatch"></a>

Amazon VPC Lattice は、ターゲットグループとサービスに関連するデータを Amazon CloudWatch に送信し、読み取り可能でほぼリアルタイムのメトリクスに加工します。これらのメトリクスは 15 か月間保持されるため、履歴情報にアクセスし、ウェブアプリケーションまたはサービスの動作をより的確に把握できます。また、特定のしきい値を監視するアラームを設定し、これらのしきい値に達したときに通知を送信したりアクションを実行したりできます。詳細については、「[Amazon CloudWatch ユーザーガイド](https://docs.aws.amazon.com//AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html)」を参照してください。

Amazon VPC Lattice は、 AWS アカウントのサービスにリンクされたロールを使用して Amazon CloudWatch にメトリクスを送信します。詳細については、「[Amazon VPC Lattice のサービスにリンクされたロールの使用](using-service-linked-roles.md)」を参照してください。

**Topics**
+ [Amazon CloudWatch メトリクスを表示する](#monitoring-cloudwatch-view)
+ [ターゲットグループのメトリクス](#monitoring-cloudwatch-tg)
+ [サービスメトリクス](#monitoring-cloudwatch-service)

## Amazon CloudWatch メトリクスを表示する
<a name="monitoring-cloudwatch-view"></a>

Amazon CloudWatch コンソールまたは AWS CLIを使用して、ターゲットグループとサービスの Amazon CloudWatch メトリクスを表示できます。

**CloudWatch コンソールを使用してメトリクスを表示するには**

1. Amazon CloudWatch コンソール ([https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/)) を開きます。

1. ナビゲーションペインで [**Metrics (メトリクス)**] を選択してください。

1. `AWS/VpcLattice` 名前空間を選択します。

1. (オプション) すべてのディメンションでメトリクスを表示するには、検索フィールドに名称を入力します。

1. (オプション) ディメンション別に検索するには、次のいずれかを選択します。
   + ターゲットグループについて報告されたメトリクスのみを表示するには、**[ターゲットグループ]** を選択します。1 つのターゲットグループのメトリクスを表示するには、検索フィールドにその名前を入力します。
   + サービスについて報告されたメトリクスのみを表示するには、**[サービス]** を選択します。1 つのサービスのメトリクスを表示するには、検索フィールドにその名前を入力します。

**を使用してメトリクスを表示するには AWS CLI**

次の [CloudWatch list-metrics](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/list-metrics.html) AWS CLI コマンドを使用して、使用可能なメトリクスを一覧表示します。

`aws cloudwatch list-metrics --namespace AWS/VpcLattice`

各メトリクスとそのディメンションの詳細については、「[ターゲットグループのメトリクス](#monitoring-cloudwatch-tg)」と「[サービスメトリクス](#monitoring-cloudwatch-service)」を参照してください。

## ターゲットグループのメトリクス
<a name="monitoring-cloudwatch-tg"></a>

VPC Lattice は、ターゲットグループに関連するメトリクスを `AWS/VpcLattice` [Amazon CloudWatch](https://docs.aws.amazon.com//AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) 名前空間に自動的に保存します。ターゲットグループの詳細については、「[VPC Lattice のターゲットグループ](target-groups.md)」を参照してください。

**ディメンション**

ターゲットグループのメトリクスをフィルタリングするには、次のディメンションを使用します。
+ `AvailabilityZone`
+ `TargetGroup`


| メトリクス | 説明 | TargetGroup プロトコル | 
| --- | --- | --- | 
|  TotalConnectionCount  |  合計接続数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  ActiveConnectionCount  |  アクティブな接続数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  ConnectionErrorCount  |  接続障害の合計。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  HTTP1\$1ConnectionCount  |  HTTP/1.1 接続の合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  HTTP2\$1ConnectionCount  |  HTTP/2 接続の合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  ConnectionTimeoutCount  |  接続タイムアウトの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  TotalReceivedConnectionBytes  |  受信した接続バイトの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  TotalSentConnectionBytes  |  送信された接続バイトの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  TotalRequestCount  |  リクエストの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  ActiveRequestCount  |  アクティブなリクエストの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  RequestTime  |  ミリ秒単位の最後のバイトへのリクエスト時間。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  HTTPCode\$12XX\$1Count, HTTPCode\$13XX\$1Count, HTTPCode\$14XX\$1Count, HTTPCode\$15XX\$1Count  |  HTTP レスポンスコードを集約します。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS  | 
|  TLSConnectionErrorCount  |  証明書検証の失敗を除く TLS 接続エラーの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 
|  TotalTLSConnectionHandshakeCount  |  成功した TLS 接続ハンドシェイクの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  |  HTTP, HTTPS, TCP  | 

## サービスメトリクス
<a name="monitoring-cloudwatch-service"></a>

VPC Lattice は、サービスに関連するメトリクスを `AWS/VpcLattice` [Amazon CloudWatch 名前空間](https://docs.aws.amazon.com//AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace)に自動的に保存します。サービスの詳細については、「[VPC Lattice のサービス](services.md)」を参照してください。

**ディメンション**

ターゲットグループのメトリクスをフィルタリングするには、次のディメンションを使用します。
+ `AvailabilityZone`
+ `Service`


| メトリクス | 説明 | 
| --- | --- | 
|  RequestTimeoutCount  |  レスポンスを待っている間にタイムアウトになったリクエストの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  | 
|  TotalRequestCount  |  リクエストの合計数。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  | 
|  RequestTime  |  ミリ秒単位のリクエスト時間。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  | 
|  HTTPCode\$12XX\$1Count, HTTPCode\$13XX\$1Count, HTTPCode\$14XX\$1Count, HTTPCode\$15XX\$1Count  |  HTTP レスポンスコードを集約します。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-cloudwatch.html)  | 

# Amazon VPC Lattice のアクセスログ
<a name="monitoring-access-logs"></a>

アクセスログは、VPC Lattice サービスとリソース設定に関する詳細情報をキャプチャします。これらのアクセスログを使用して、トラフィックパターンを分析し、ネットワーク内のすべてのサービスを監査できます。VPC Lattice サービスでは、 を公開`VpcLatticeAccessLogs`し、リソース設定では、個別に設定する必要がある `VpcLatticeResourceAccessLogs` を公開します。

アクセスログはオプションであり、デフォルトでは無効になっています。アクセスログを有効にした後は、いつでも無効にできます。

**料金**  
アクセスログが公開されると料金が発生します。ユーザーに代わって AWS ネイティブに発行するログは*、販売ログ*と呼ばれます。Vended Logs の料金の詳細については、「[Amazon CloudWatch 料金表](https://aws.amazon.com/cloudwatch/pricing/)」を参照してください。**[ログ]**を選択すると、**[Vended Logs]** の下に価格が表示されます。

**Topics**
+ [アクセスログを有効にするために必要な IAM アクセス許可](#monitoring-access-logs-IAM)
+ [アクセスログの送信先](#monitoring-access-logs-destinations)
+ [アクセスログの有効化](#monitoring-access-logs-enable)
+ [リクエストの追跡](#x-amzn-RequestId-enable)
+ [アクセスログの内容](#monitoring-access-logs-contents)
+ [リソースアクセスログの内容](#monitoring-resource-access-logs-contents)
+ [アクセスログのトラブルシューティング](#monitoring-access-logs-troubleshoot)

## アクセスログを有効にするために必要な IAM アクセス許可
<a name="monitoring-access-logs-IAM"></a>

アクセスログを有効にしてログを送信先に送信するには、使用している IAM ユーザー、グループ、またはロールにアタッチされたポリシーで次のアクションが必要です。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Sid": "ManageVPCLatticeAccessLogSetup",
            "Action": [
                "logs:CreateLogDelivery",
                "logs:GetLogDelivery",
                "logs:UpdateLogDelivery",
                "logs:DeleteLogDelivery",
                "logs:ListLogDeliveries",
                "vpc-lattice:CreateAccessLogSubscription",
                "vpc-lattice:GetAccessLogSubscription",
                "vpc-lattice:UpdateAccessLogSubscription",
                "vpc-lattice:DeleteAccessLogSubscription",
                "vpc-lattice:ListAccessLogSubscriptions"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
```

------

詳細については、[AWS Identity and Access Management ユーザーガイド]の「[IAM ID アクセス許可の追加と削除](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-attach-detach.html)」を参照してください。

IAM ユーザー、IAM グループ、または使用している IAM ロールにアタッチされているポリシーを更新したら、[アクセスログの有効化](#monitoring-access-logs-enable) に進みます。

## アクセスログの送信先
<a name="monitoring-access-logs-destinations"></a>

アクセスログは、次の宛先に送信できます。

**Amazon CloudWatch Logs**
+ VPC Lattice は通常 2 分以内に CloudWatch Logs にログを配信します。ただし、実際のログ配信時間はベストエフォートベースであり、さらにレイテンシーが発生する可能性があることに注意してください。
+ ロググループに特定の権限がない場合は、リソースポリシーが自動的に作成され、CloudWatch ロググループに追加されます。詳細については、「Amazon CloudWatch ユーザーガイド」の「[CloudWatch Logs に送信されたログ](https://docs.aws.amazon.com//AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html#AWS-logs-infrastructure-CWL)」を参照してください。
+ CloudWatch に送信されたアクセスログは、CloudWatch コンソールの [ロググループ] で確認できます。詳細については、「Amazon CloudWatch ユーザーガイド」の「[CloudWatch Logs に送信されたログデータを表示する](https://docs.aws.amazon.com//AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html#ViewingLogData)」を参照してください。

**Amazon S3**
+ VPC Lattice は通常 6 分以内に Amazon S3 にログを配信します。ただし、実際のログ配信時間はベストエフォートベースであり、さらにレイテンシーが発生する可能性があることに注意してください。
+ バケットに特定の権限がない場合は、バケットポリシーが自動的に作成され、Amazon S3 バケットに追加されます。詳細については、「Amazon CloudWatch ユーザーガイド」の「[Amazon S3 に送信されたログ](https://docs.aws.amazon.com//AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html#AWS-logs-infrastructure-S3)」を参照してください。
+ Amazon S3 に送信されるアクセスログには、次の命名規則が使用されます。

  ```
  [bucket]/[prefix]/AWSLogs/[accountId]/VpcLattice/AccessLogs/[region]/[YYYY/MM/DD]/[resource-id]/[accountId]_VpcLatticeAccessLogs_[region]_[resource-id]_YYYYMMDDTHHmmZ_[hash].json.gz
  ```
+ Amazon S3 に送信される VpcLatticeResourceAccessLogs は、次の命名規則を使用します。

  ```
  [bucket]/[prefix]/AWSLogs/[accountId]/VpcLattice/ResourceAccessLogs/[region]/[YYYY/MM/DD]/[resource-id]/[accountId]_VpcLatticeResourceAccessLogs_[region]_[resource-id]_YYYYMMDDTHHmmZ_[hash].json.gz
  ```

**Amazon Data Firehose**
+ VPC Lattice は通常、2 分以内に Firehose にログを配信します。ただし、実際のログ配信時間はベストエフォートベースであり、さらにレイテンシーが発生する可能性があることに注意してください。
+ アクセスログを Amazon Data Firehoseに送信する権限を VPC Lattice に付与するサービスにリンクされたロールが自動的に作成されます。この自動ロール作成が正常に行われるには、ユーザーが `iam:CreateServiceLinkedRole` アクションに対する許可を持っている必要があります。詳細については、「Amazon CloudWatch ユーザーガイド」の「[Amazon Data Firehoseにログを送信する](https://docs.aws.amazon.com//AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html#AWS-logs-infrastructure-Firehose)」を参照してください。
+  Amazon Data Firehoseに送信されたログの表示の詳細については、「Amazon Data Firehose デベロッパーガイド」の「[Amazon Kinesis Data Streams のモニタリング](https://docs.aws.amazon.com//streams/latest/dev/monitoring.html)」を参照してください。

## アクセスログの有効化
<a name="monitoring-access-logs-enable"></a>

次の手順を実行して、アクセスログを取得し、選択した宛先に配信するように設定します。

**Topics**
+ [コンソールを使用してアクセスログを有効にする](#monitoring-access-logs-console)
+ [を使用してアクセスログを有効にする AWS CLI](#monitoring-access-logs-cli)

### コンソールを使用してアクセスログを有効にする
<a name="monitoring-access-logs-console"></a>

作成時に、サービスネットワーク、サービス、またはリソース設定のアクセスログを有効にできます。次の手順で説明するように、サービスネットワーク、サービス、またはリソース設定を作成した後にアクセスログを有効にすることもできます。

**コンソールを使用して基本サービスを作成するには**

1. Amazon VPC コンソールの [https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/) を開いてください。

1. サービスネットワーク、サービス、またはリソースの設定を選択します。

1. **[アクション]**、**[ログ設定を編集]** の順に選択します。

1. **[アクセスログ]** トグルスイッチをオンにします。

1. アクセスログの配信先を次のように追加します。
   + **[CloudWatch ロググループ]** を選択し、ロググループを選択します。ロググループを作成するには、**[CloudWatch でロググループを作成する]** を選択します。
   + **[S3 バケット]** を選択し、プレフィックスを含む S3 バケットパスを入力します。S3 バケットを検索するには、**[S3 を参照]** を選択します。
   + **[Kinesis Data Firehose 配信ストリーム]** を選択し、配信ストリームを選択します。配信ストリームを作成するには、**[Kinesis で配信ストリームを作成]** を選択します。

1. **[Save changes]** (変更の保存) をクリックします。

### を使用してアクセスログを有効にする AWS CLI
<a name="monitoring-access-logs-cli"></a>

CLI コマンド [create-access-log-subscription](https://docs.aws.amazon.com/cli/latest/reference/vpc-lattice/create-access-log-subscription.html) を使用して、サービスネットワークまたはサービスのアクセスログを有効にします。

## リクエストの追跡
<a name="x-amzn-RequestId-enable"></a>

 VPC Lattice は、x-amzn-requestid ヘッダーによるオブザーバビリティとデバッグのために、クライアント、ターゲット、ログ間のリクエストの追跡と相関をサポートします。このヘッダーは、クライアントによって設定および送信することも、VPC Lattice によって生成することもでき、ターゲットに送信され、アクセスログでも使用できます。

**デフォルトの 動作**
+ VPC Lattice は、リクエストごとにこのヘッダーを自動的に生成します。
+ 値はランダムに生成された識別子です (デフォルトでは UUID スタイル）。
+ 生成された識別子は次のとおりです。
  + ダウンストリームターゲットに伝播されます。
  +  レスポンスヘッダーでクライアントに返されます。
  + アクセスログへのログイン

**例 (デフォルトレスポンス)**  
以下に、VPC Lattice のデフォルト動作でクライアントに送信されるレスポンスの例を示します。このレスポンスは、valu eof x-amzn-requestid ヘッダーのランダムな値を生成します。

```
{
    "HTTP/1.1 200 OK
    x-amzn-requestid: a9f2c7a1-6b4f-4c79-9e87-ff5a1234a001"
}
```

**値を設定するクライアント**
+ クライアントは、オプションで受信リクエストにこのヘッダーを設定して、自動的に生成された値を上書きできます。
+ 考慮事項
  +  ヘッダー値は UUID 形式に従う必要はありません。
  + ヘッダー値が 512 バイトを超える場合、VPC Lattice はそれを 512 に切り捨てます。
+  正常に上書きされると、指定されたヘッダー値は次のようになります。
  + レスポンスヘッダーに表示される
  + ターゲットに伝達される
  + アクセスログとメトリクスに表示される

**例 (クライアントリクエストの上書き)**  
以下は、ヘッダー値を持つクライアントから送信されたリクエストの例です。

```
{
    "GET /my-service/endpoint HTTP/1.1 
    Host: my-api.example.com
    x-amzn-requestid: trace-request-foobar"
}
```

**例 (デフォルトのオーバーライドレスポンス)**  
以下は、オーバーライドされた値でクライアントに送信されるレスポンスの例です。

```
{
    "HTTP/1.1 200 OK
    x-amzn-requestid: trace-request-foobar"
}
```

## アクセスログの内容
<a name="monitoring-access-logs-contents"></a>

次の表は、アクセスログのエントリのフィールドを示しています。


| フィールド | 説明 | 形式 | 
| --- | --- | --- | 
|  callerPrincipalTags  |  リクエストの PrincipalTags。  | JSON | 
|  hostHeader  |  リクエストの権限ヘッダー。  |  string  | 
|  sslCipher  |  クライアント TLS 接続を確立するために使用される暗号セットの OpenSSL 名。  |  string  | 
|  serviceNetworkArn  |  サービスネットワーク ARN。  |  arn:aws:vpc-lattice:*region*:*account*:servicenetwork/*id*  | 
|  resolvedUser  |  認証が有効な場合に認証が行われたときのユーザーの ARN。  |  null \$1 ARN \$1 "Anonymous" \$1 "Unknown"  | 
|  authDeniedReason  |  認証が有効な場合にアクセスが拒否される理由。  |  null \$1 "Service" \$1 "Network" \$1 "Identity"  | 
|  requestMethod  |  リクエストのメソッドヘッダー。  |  string  | 
|  targetGroupArn  |  ターゲットホストが属するターゲットホストグループ。  |  string  | 
|  tlsVersion  |  TLS バージョン。  |  TLSv*x*  | 
|  userAgent  |  ユーザーエージェントヘッダー。  |  string  | 
|  serverNameIndication  |  [HTTPS のみ] ssl 接続ソケットに設定された Server Name Indication (SNI) の値。  |  string  | 
|  destinationVpcId  |  送信先 VPC ID。  |  vpc-*xxxxxxxx*  | 
|  sourceIpPort  |  送信元の IP アドレスとポート。  |  *ip*:*port*  | 
|  targetIpPort  |  ターゲットの IP アドレスとポート。  |  *ip*:*port*  | 
|  serviceArn  |  サービス ARN。  |  arn:aws:vpc-lattice:*region*:*account*:service/*id*  | 
|  sourceVpcId  |  ソース VPC ID。  |  vpc-*xxxxxxxx*  | 
|  requestPath  |  リクエストのパス。  |  LatticePath?:*path*  | 
|  startTime  |  リクエストの開始時刻。  |  *YYYY*-*MM*-*DD*T*HH*:*MM*:*SS*Z  | 
|  protocol  |  プロトコル。現在は HTTP/1.1 または HTTP/2。  |  string  | 
|  responseCode  |  HTTP レスポンスコード。最終ヘッダーのレスポンスコードのみが記録されます。詳細については、「[アクセスログのトラブルシューティング](#monitoring-access-logs-troubleshoot)」を参照してください。  |  integer  | 
|  bytesReceived  |  受信した本文とヘッダーのバイト数。  |  integer  | 
|  bytesSent  |  送信された本文とヘッダーのバイト数。  |  integer  | 
|  duration  |  リクエストの開始時刻から最後のバイトが送信されるまでの合計期間 (ミリ秒単位)。  |  integer  | 
|  requestToTargetDuration  |  リクエストの開始時刻から最後のバイトがターゲットに送信されるまでの合計期間 (ミリ秒単位)。  |  integer  | 
|  responseFromTargetDuration  |  リクエストの最初のバイトがターゲットホストから読み取られてから、最後のバイトがクライアントに送信されるまでの合計期間 (ミリ秒単位)。  |  integer  | 
|  grpcResponseCode  |  gRPC レスポンスコード。詳細については、「[Status codes and their use in gRPC](https://grpc.github.io/grpc/core/md_doc_statuscodes.html)」を参照してください。このフィールドは、サービスが gRPC をサポートしている場合にのみ記録されます。  |  integer  | 
|  requestId  |  これは、x-amzn-requestid ヘッダーの値としてレスポンスに自動的に含まれる一意の識別子です。これにより、クライアント、ターゲット、ログ間のリクエストの相関関係が可能になり、オブザーバビリティとデバッグが可能になります。  |  string  | 
|  callerPrincipal  |  認証されたプリンシパル。  |  string  | 
|  callerX509SubjectCN  |  サブジェクト名 (CN)。  |  string  | 
|  callerX509IssuerOU  |  発行者 (OU)。  |  string  | 
|  callerX509SANNameCN  |  発行者の代替 (名前/CN)。  |  string  | 
|  callerX509SANDNS  |  サブジェクト代替名 (DNS)。  |  string  | 
|  callerX509SANURI  |  サブジェクト代替名 (URI)。  |  string  | 
|  sourceVpcArn  |  リクエストが発生した VPC の ARN。  |  arn:aws:ec2:*region*:*account*:vpc/*id*  | 
| failureReason | リクエストが失敗した理由を示します。取り得る値には以下のものがあります。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-access-logs.html) | string | 

**例**  
ログエントリの例を示します。

```
{
    "callerPrincipalTags" : "{ "TagA": "ValA", "TagB": "ValB", ... }",
    "hostHeader": "example.com",
    "sslCipher": "-",
    "serviceNetworkArn": "arn:aws:vpc-lattice:us-west-2:123456789012:servicenetwork/svn-1a2b3c4d",
    "resolvedUser": "Unknown",
    "authDeniedReason": "null",
    "requestMethod": "GET",
    "targetGroupArn": "arn:aws:vpc-lattice:us-west-2:123456789012:targetgroup/tg-1a2b3c4d",
    "tlsVersion": "-",
    "userAgent": "-",
    "serverNameIndication": "-",
    "destinationVpcId": "vpc-0abcdef1234567890",
    "sourceIpPort": "178.0.181.150:80",
    "targetIpPort": "131.31.44.176:80",
    "serviceArn": "arn:aws:vpc-lattice:us-west-2:123456789012:service/svc-1a2b3c4d",
    "sourceVpcId": "vpc-0abcdef1234567890",
    "requestPath": "/billing",
    "startTime": "2023-07-28T20:48:45Z",
    "protocol": "HTTP/1.1",
    "responseCode": 200,
    "bytesReceived": 42,
    "bytesSent": 42,
    "duration": 375,
    "requestToTargetDuration": 1,
    "responseFromTargetDuration": 1,
    "grpcResponseCode": 1,
    "requestId": "a9f2c7a1-6b4f-4c79-9e87-ff5a1234a001"
}
```

## リソースアクセスログの内容
<a name="monitoring-resource-access-logs-contents"></a>

次の表に、リソースアクセスログエントリのフィールドを示します。


| フィールド | 説明 | 形式 | 
| --- | --- | --- | 
|  serviceNetworkArn  |  サービスネットワーク ARN。  |  arn:*partition* vpc-lattice:*region*:*account*:servicenetwork/*id*  | 
|  serviceNetworkResourceAssociationId  |  サービスネットワークリソース ID。  |  *snra*-*xxx*  | 
|  vpcEndpointId  |  リソースへのアクセスに使用されたエンドポイント ID。  |  string  | 
|  sourceVpcArn  |  接続が開始されたソース VPC ARN または VPC。  |  string  | 
|  resourceConfigurationArn  |  アクセスされたリソース設定の ARN。  |  string  | 
|  protocol  |  リソース設定との通信に使用されるプロトコル。現在、tcp のみがサポートされています。  |  string  | 
|  sourceIpPort  |  接続を開始したソースの IP アドレスとポート。  |  *ip*:*port*  | 
|  destinationIpPort  |  接続が開始された IP アドレスとポート。これは SN-E/SN-A の IP になります。  |  *ip*:*port*  | 
|  gatewayIpPort  |  リソースゲートウェイがリソースにアクセスするために使用する IP アドレスとポート。  |  *ip*:*port*  | 
|  resourceIpPort  |  リソースの IP アドレスとポート。  |  *ip*:*port*  | 

**例**  
ログエントリの例を示します。

```
{
    "eventTimestamp": "2024-12-02T10:10:10.123Z",
    "serviceNetworkArn": "arn:aws:vpc-lattice:us-west-2:1234567890:servicenetwork/sn-1a2b3c4d",
    "serviceNetworkResourceAssociationId": "snra-1a2b3c4d",
    "vpcEndpointId": "vpce-01a2b3c4d",
    "sourceVpcArn": "arn:aws:ec2:us-west-2:1234567890:vpc/vpc-01a2b3c4d",
    "resourceConfigurationArn": "arn:aws:vpc-lattice:us-west-2:0987654321:resourceconfiguration/rcfg-01a2b3c4d",
    "protocol": "tcp",
    "sourceIpPort": "172.31.23.56:44076",
    "destinationIpPort": "172.31.31.226:80",
    "gatewayIpPort": "10.0.28.57:49288",
    "resourceIpPort": "10.0.18.190:80"
}
```

## アクセスログのトラブルシューティング
<a name="monitoring-access-logs-troubleshoot"></a>

このセクションでは、アクセスログに表示される可能性のある HTTP エラーコードについて説明します。


| エラーコード | 考えられる原因 | 
| --- | --- | 
|  HTTP 400: Bad Request  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/vpc-lattice/latest/ug/monitoring-access-logs.html)  | 
|  HTTP 403: Forbidden  |  認証はサービスに対して設定されているが、受信リクエストは認証も承認もされていない。  | 
|  HTTP 404: Non Existent Service  |  存在しないサービスに接続しようとしているか、適切なサービスネットワークに登録されていない。  | 
|  HTTP 500: 内部サーバーエラー  |  VPC Lattice でターゲットに接続できないなどのエラーが発生した。  | 
|  HTTP 502: Bad Gateway  |  VPC Lattice でエラーが発生した。  | 

# Amazon VPC Lattice の CloudTrail ログ
<a name="monitoring-cloudtrail"></a>

Amazon VPC Lattice は、ユーザー[AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)、ロール、または によって実行されたアクションを記録するサービスである と統合されています AWS のサービス。CloudTrail は、VPC Lattice のすべての API コールをイベントとしてキャプチャします。キャプチャされた呼び出しには、VPC Lattice コンソールからの呼び出しと、VPC Lattice API オペレーションへのコード呼び出しが含まれます。CloudTrail で収集された情報を使用して、VPC Lattice に対するリクエスト、リクエスト元の IP アドレス、リクエスト日時などの詳細を確認できます。

各イベントまたはログエントリには、誰がリクエストを生成したかという情報が含まれます。アイデンティティ情報は、以下を判別するのに役立ちます。
+ ルートユーザーまたはユーザー認証情報のどちらを使用してリクエストが送信されたか。
+ リクエストが IAM Identity Center ユーザーに代わって行われたかどうか。
+ リクエストがロールまたはフェデレーションユーザーのテンポラリなセキュリティ認証情報を使用して行われたかどうか。
+ リクエストが、別の AWS のサービスによって送信されたかどうか。

CloudTrail は、アカウントを作成する AWS アカウント と でアクティブになり、CloudTrail **イベント履歴**に自動的にアクセスできます。CloudTrail の **[イベント履歴]** では、 AWS リージョンで過去 90 日間に記録された管理イベントの表示、検索、およびダウンロードが可能で、変更不可能な記録を確認できます。詳細については、「*AWS CloudTrail ユーザーガイド*」の「[CloudTrail イベント履歴の使用](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)」を参照してください。**[イベント履歴]** の閲覧には CloudTrail の料金はかかりません。

 AWS アカウント 過去 90 日間のイベントの継続的な記録については、証跡または [CloudTrail Lake](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html) イベントデータストアを作成します。

**CloudTrail 証跡**  
*証跡*により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。を使用して作成されたすべての証跡 AWS マネジメントコンソール はマルチリージョンです。 AWS CLIを使用する際は、単一リージョンまたは複数リージョンの証跡を作成できます。アカウント AWS リージョン 内のすべての でアクティビティをキャプチャするため、マルチリージョン証跡を作成することをお勧めします。単一リージョンの証跡を作成する場合、証跡の AWS リージョンに記録されたイベントのみを表示できます。証跡の詳細については、「*AWS CloudTrail ユーザーガイド*」の「[AWS アカウントの証跡の作成](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)」および「[組織の証跡の作成](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)」を参照してください。  
証跡を作成すると、進行中の管理イベントのコピーを 1 つ無料で CloudTrail から Amazon S3 バケットに配信できますが、Amazon S3 ストレージには料金がかかります。CloudTrail の料金の詳細については、「[AWS CloudTrail の料金](https://aws.amazon.com/cloudtrail/pricing/)」を参照してください。Amazon S3 の料金に関する詳細については、「[Amazon S3 の料金](https://aws.amazon.com/s3/pricing/)」を参照してください。

**CloudTrail Lake イベントデータストア**  
*[CloudTrail Lake]* を使用すると、イベントに対して SQL ベースのクエリを実行できます。CloudTrail Lake は、行ベースの JSON 形式の既存のイベントを [Apache ORC](https://orc.apache.org/) 形式に変換します。ORC は、データを高速に取得するために最適化された単票ストレージ形式です。イベントは、*イベントデータストア*に集約されます。イベントデータストアは、[高度なイベントセレクタ](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-concepts.html#adv-event-selectors)を適用することによって選択する条件に基づいた、イベントのイミュータブルなコレクションです。どのイベントが存続し、クエリに使用できるかは、イベントデータストアに適用するセレクタが制御します。CloudTrail Lake の詳細については、 *AWS CloudTrail ユーザーガイド*の[AWS CloudTrail 「Lake の使用](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html)」を参照してください。  
CloudTrail Lake のイベントデータストアとクエリにはコストがかかります。イベントデータストアを作成する際に、イベントデータストアに使用する[料金オプション](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-manage-costs.html#cloudtrail-lake-manage-costs-pricing-option)を選択します。料金オプションによって、イベントの取り込みと保存にかかる料金、および、そのイベントデータストアのデフォルトと最長の保持期間が決まります。CloudTrail の料金の詳細については、「[AWS CloudTrail の料金](https://aws.amazon.com/cloudtrail/pricing/)」を参照してください。

その他のアクションをモニタリングするには、アクセスログを使用します。詳細については、「[アクセスログ](monitoring-access-logs.md)」を参照してください。

## CloudTrail での VPC Lattice 管理イベント
<a name="cloudtrail-management-events"></a>

[管理イベント](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events)は、 のリソースで実行される管理オペレーションに関する情報を提供します AWS アカウント。これらのイベントは、コントロールプレーンオペレーションとも呼ばれます。CloudTrail は、デフォルトで管理イベントをログ記録します。

Amazon VPC Lattice は、VPC Lattice コントロールプレーンオペレーションを管理イベントとしてログに記録します。VPC Lattice が CloudTrail にログ記録する Amazon VPC Lattice コントロールプレーンオペレーションのリストについては、[「Amazon VPC Lattice API リファレンス](https://docs.aws.amazon.com/vpc-lattice/latest/APIReference/)」を参照してください。

## VPC Lattice イベントの例
<a name="cloudtrail-event-examples"></a>

各イベントは任意の送信元からの単一のリクエストを表し、リクエストされた API オペレーション、オペレーションの日時、リクエストパラメータなどに関する情報を含みます。CloudTrail ログファイルは、パブリック API コールの順序付けられたスタックトレースではないため、イベントは特定の順序で表示されません。

次の例は、[CreateService](https://docs.aws.amazon.com/vpc-lattice/latest/APIReference/API_CreateService.html) オペレーションの CloudTrail イベントを示しています。

```
{
  "eventVersion": "1.08",
  "userIdentity": {
    "type": "AssumedRole",
    "principalId": "abcdef01234567890",
    "arn": "arn:abcdef01234567890",
    "accountId": "abcdef01234567890",
    "accessKeyId": "abcdef01234567890",
    "sessionContext": {
        "sessionIssuer": {
            "type": "Role",
            "principalId": "abcdef01234567890",
            "arn": "arn:abcdef01234567890",
            "accountId": "abcdef01234567890",
            "userName": "abcdef01234567890"
        },
        "webIdFederationData": {},
        "attributes": {
            "creationDate": "2022-08-16T03:34:54Z",
            "mfaAuthenticated": "false"
        }
    }
  },
  "eventTime": "2022-08-16T03:36:12Z",
  "eventSource": "vpc-lattice.amazonaws.com",
  "eventName": "CreateService",
  "awsRegion": "us-west-2",
  "sourceIPAddress": "abcdef01234567890",
  "userAgent": "abcdef01234567890",
  "requestParameters": {
    "name": "rates-service"
  },
  "responseElements": {
    "name": "rates-service",
    "id": "abcdef01234567890",
    "arn": "arn:abcdef01234567890",
    "status": "CREATE_IN_PROGRESS"
  },
  "requestID": "abcdef01234567890",
  "eventID": "abcdef01234567890",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "managementEvent": true,
  "recipientAccountId": "abcdef01234567890",
  "eventCategory": "Management"
}
```

次の例は、[DeleteService](https://docs.aws.amazon.com/vpc-lattice/latest/APIReference/API_DeleteService.html) オペレーションの CloudTrail イベントを示しています。

```
{
  "eventVersion": "1.08",
  "userIdentity": {
    "type": "AssumedRole",
    "principalId": "abcdef01234567890",
    "arn": "arn:ABCXYZ123456",
    "accountId": "abcdef01234567890",
    "accessKeyId": "abcdef01234567890",
    "sessionContext": {
        "sessionIssuer": {
            "type": "Role",
            "principalId": "abcdef01234567890",
            "arn": "arn:aws:iam::AIDACKCEVSQ6C2EXAMPLE:role/Admin",
            "accountId": "abcdef01234567890",
            "userName": "Admin"
        },
        "webIdFederationData": {},
        "attributes": {
            "creationDate": "2022-10-27T17:42:36Z",
            "mfaAuthenticated": "false"
        }
    }
  },
  "eventTime": "2022-10-27T17:56:41Z",
  "eventSource": "vpc-lattice.amazonaws.com",
  "eventName": "DeleteService",
  "awsRegion": "us-east-1",
  "sourceIPAddress": "72.21.198.64",
  "userAgent": "abcdef01234567890",
  "requestParameters": {
    "serviceIdentifier": "abcdef01234567890"
  },
  "responseElements": {
    "name": "test",
    "id": "abcdef01234567890",
    "arn": "arn:abcdef01234567890",
    "status": "DELETE_IN_PROGRESS"
  },
  "requestID": "abcdef01234567890",
  "eventID": "abcdef01234567890",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "managementEvent": true,
  "recipientAccountId": "abcdef01234567890",
  "eventCategory": "Management"       
}
```

CloudTrail レコードの内容については、「*AWS CloudTrail ユーザーガイド*」の「[CloudTrail record contents](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html)」を参照してください。