

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

# Amazon EventBridge イベントを使用して画面録画ステータスを追跡する
<a name="track-screen-recording-status"></a>

Amazon EventBridge を使用すると、[エージェント画面録画](agent-screen-recording.md)のステータスをほぼリアルタイムで表示できます。各エージェントの画面録画のイベントには、成功/失敗ステータス、説明を含む失敗コード、録画場所、録画サイズ、インストールされたクライアントバージョン、画面録画の開始時刻と終了時刻が含まれます。

を他の AWS サービスと統合して、エージェントの画面録画の分析またはモニタリングに関するインサイトを取得できます。
+ [Amazon CloudWatch Log Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html) を使用したクエリ
+ [Amazon Quick](https://aws.amazon.com/quicksight/) ダッシュボードでほぼリアルタイムのアラートを取得する
+ Amazon Connect の外部で集計レポートを作成する
+ 他のカスタマイズされたデータパイプラインソリューションを Amazon EventBridge に接続する

**Topics**
+ [Amazon EventBridge イベントペイロード形式](#eventbridge-payload-formats)
+ [Amazon EventBridge イベントに一致するルールを作成する](#create-eventbridge-rule)
+ [作成した Amazon EventBridge ルールのターゲットを設定する](#configure-eventbridge-target)

## Amazon EventBridge イベントペイロード形式
<a name="eventbridge-payload-formats"></a>

### 画面録画ステータスのイベント - INITIATED
<a name="event-initiated"></a>

このイベントは、エージェントが問い合わせを承諾したときに出力されます。これは、エージェントの画面録画が有効になっているすべての問い合わせについて、記録が開始される前である可能性があります。

```
{  
  "version": "0",  
  "id": "the_event_id_from_eventbridge",  
  "detail-type": "Screen Recording Status Changed",  
  "source": "aws.connect",  
  "account": "your_aws_account_id",  
  "time": "2026-01-01T00:00:00Z",  
  "region": "us-west-2",  
  "resources": [  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/your_contact_id",  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id"  
  ],  
  "detail": {  
    "version": "1.0",  
    "recordingStatus": "INITIATED",  
    "eventDeduplicationId": "unique_uuid",  
    "instanceArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id",  
    "contactArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/your_contact_id",  
    "agentArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/agent/your_agent_id",  
    "clientInfo": {  
      "appVersion": "2.0.3.0",  
    }  
  }  
}
```

### 画面録画ステータスのイベント - 完了
<a name="event-completed"></a>

このイベントは、エージェントのデスクトップで画面録画が終了すると出力されます。これは、画面録画が Amazon S3 バケットに正常にアップロードされたことを意味するものではありません。

```
{  
  "version": "0",  
  "id": "the_event_id_from_eventbridge",  
  "detail-type": "Screen Recording Status Changed",  
  "source": "aws.connect",  
  "account": "your_aws_account_id",  
  "time": "2026-01-01T00:00:00Z",  
  "region": "us-west-2",  
  "resources": [  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/your_contact_id",  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id"  
  ],  
  "detail": {  
    "version": "1.0",  
    "recordingStatus": "COMPLETED",  
    "eventDeduplicationId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeee",  
    "instanceArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id",  
    "contactArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/your_contact_id",  
    "agentArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/agent/your_agent_id",  
    "clientInfo": {  
      "appVersion": "2.0.3.0",  
    },  
    "recordingInfo": {  
      "startTime": "2026-01-01T00:00:00.000Z",  
      "endTime": "2026-01-01T00:00:00.000Z",  
    }  
  }  
}
```

### 画面録画ステータスのイベント - 公開済み
<a name="event-published"></a>

このイベントは、画面録画が Amazon S3 バケットに正常にアップロードされたときに出力されます。詳細には、Amazon S3 バケットの場所、記録サイズ、記録期間が含まれます。

```
{  
  "version": "0",  
  "id": "the_event_id_from_eventbridge",  
  "detail-type": "Screen Recording Status Changed",  
  "source": "aws.connect",  
  "account": "your_aws_account_id",  
  "time": "2026-01-01T00:00:00Z",  
  "region": "us-west-2",  
  "resources": [  
    "contactArn",  
    "instanceArn"  
  ],  
  "detail": {  
    "version": "1.0",  
    "recordingStatus": "PUBLISHED",  
    "eventDeduplicationId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeee",  
    "instanceArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id",  
    "contactArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/your_contact_id",  
    "agentArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/agent/your_agent_id",  
    "clientInfo": {  
      "appVersion": "2.0.3.0",  
    },  
    "recordingInfo": {  
      "startTime": "2026-01-01T00:00:00.000Z",  
      "endTime": "2026-01-01T00:00:00.000Z",  
      "publishTime": "2026-01-01T00:00:00.000Z",  
      "location": "s3://your-bucket-name/object-prefix/object-key",  
      "durationInMillis": 100000,  
      "sizeInBytes": 1000000  
    }  
  }  
}
```

### 画面録画ステータスのイベント - 失敗
<a name="event-failed"></a>

このイベントは、画面録画が失敗した場合に出力されます。障害情報の詳細は、検出可能な障害理由のベストエフォート推定として提供されます。

```
{  
  "version": "0",  
  "id": "the_event_id_from_eventbridge",  
  "detail-type": "Screen Recording Status Changed",  
  "source": "aws.connect",  
  "account": "your_aws_account_id",  
  "time": "2026-01-01T00:00:00Z",  
  "region": "us-west-2",  
  "resources": [  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/cccccccc-cccc-cccc-cccc-ccccccccccccc",  
    "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id"  
  ],  
  "detail": {  
    "version": "1.0",  
    "recordingStatus": "FAILED",  
    "eventDeduplicationId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeee",  
    "instanceArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id",  
    "contactArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/contact/cccccccc-cccc-cccc-cccc-ccccccccccccc",  
    "agentArn": "arn:aws:connect:us-west-2:your_aws_account_id:instance/your_instance_id/agent/your_agent_id",  
    "clientInfo": {  
      "appVersion": "2.0.3.0",  
    },  
    "failureInfo": {  
      "code": "UNKNOWN",  
      "message": "UNKNOWN",  
      "source": "Unknown failure"  
    },  
    "recordingInfo": {  
      "startTime": "2026-01-01T00:00:00.000Z"  
    }  
  }  
}
```

## Amazon EventBridge イベントに一致するルールを作成する
<a name="create-eventbridge-rule"></a>

画面録画ステータスの Amazon EventBridge イベントをサブスクライブするには、定義されたイベントソースとイベント詳細タイプに一致する Amazon EventBridge ルールを作成する必要があります。これは、 AWS コンソールまたは AWS CDK ライブラリを使用して実現できます。

### AWS コンソールを使用してルールを作成する
<a name="create-rule-console"></a>

 AWS コンソールで、Amazon EventBridge → Buses → Rules で新しいルールを作成します。

#### デフォルトのイベントバスを使用する
<a name="use-default-event-bus"></a>

![デフォルトのイベントバスの選択を示すルールの作成ページ。](http://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/images/screen-recording-eventbridge-event-rule.png)


#### テンプレートイベントパターンを使用する
<a name="use-template-event-pattern"></a>

ドロップダウンリストから定義されたイベントパターンを選択します。

![aws.connect が選択されたことを示すイベントソースドロップダウン。](http://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/images/screen-recording-eventbridge-event-source.png)


![画面録画ステータスが変更されたことを示すイベントパターン。](http://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/images/screen-recording-eventbridge-event-pattern.png)


イベントタイプがドロップダウンリストに表示されない場合は、カスタムパターン **(JSON エディタ) を使用して同じパターン**を次のように作成することもできます。

```
{  
  "source": [ "aws.connect" ],  
  "detailType": [ "Screen Recording Status Changed" ]  
}
```

### を使用してルールを作成する AWS CDK
<a name="create-rule-cdk"></a>

または、 で AWS リソースを管理する場合 AWS CDK、Amazon EventBridge ルールを構築するための TypeScript コードスニペットの例を次に示します。

```
import { Rule } from 'aws-cdk-lib/aws-events';  
  
const eventBridgeRule = new Rule(this, 'YourEventBridgeRuleLogicalName', {  
    ruleName: 'your-event-bridge-rule-name',  
    description: 'your rule description',  
    eventPattern: {  
        source: [ "aws.connect" ],  
        detailType: [ "Screen Recording Status Changed" ]  
    }  
});
```

## 作成した Amazon EventBridge ルールのターゲットを設定する
<a name="configure-eventbridge-target"></a>

Amazon EventBridge は、ターゲットとして多くの AWS サービスをサポートしています。必要に応じて、他の AWS サービスを使用して独自のイベント処理パイプラインを柔軟に構築できます。ルールごとに最大 5 つのターゲットを定義できます。詳細については、「*Amazon EventBridge ユーザーガイド*」の「[Amazon EventBridge ターゲット](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-targets.html)」を参照してください。

### ターゲット例としての Amazon CloudWatch ロググループ
<a name="cloudwatch-log-group-target"></a>

次の例では、[Amazon CloudWatch ロググループ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html)をターゲットとして使用します。

![選択した CloudWatch ロググループを示すターゲット設定。](http://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/images/screen-recording-eventbridge-target-cwl.png)


 AWS CDK コードで、リソースを作成し、Amazon EventBridge ルールに追加します。

```
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";  
import { CloudWatchLogGroup } from 'aws-cdk-lib/aws-events-targets';  
   
const logGroup = new LogGroup(this, 'YourLogGroupLogicalName', {  
    logGroupName: '"/aws/events/your-log-group-name',  
    retention: RetentionDays.ONE_YEAR  
});  
  
eventBridgeRule.addTarget(new CloudWatchLogGroup((logGroup)));
```

#### Amazon CloudWatch Log Insights クエリの例
<a name="cloudwatch-log-insights-queries"></a>

Amazon CloudWatch Insights クエリ言語を使用したクエリの例を次に示します。
+ **成功率のサンプルクエリ**

  ```
  fields @timestamp, @message, detail  
  | stats sum(detail.recordingStatus= "PUBLISHED") as Count_Success,   
    sum(detail.recordingStatus= "INITIATED") as Count_Total,   
    Count_Success / Count_Total as Success_Ratio
  ```
+ **各記録ステータスの数を取得するためのサンプルクエリ**

  ```
  fields @timestamp, @message, detail  
  | stats count(*) as Count group by detail.recordingStatus as recordingStatus
  ```
+ **最も一般的な障害コードを持つ失敗した問い合わせに対するサンプルクエリ**

  ```
  fields @timestamp, @message, detail  
  | filter detail.recordingStatus = "FAILED"   
  | stats count(*) as Count group by detail.failureInfo.code as FailureCode  
  | sort by Count desc
  ```
+ **問い合わせが最も失敗したエージェントのサンプルクエリ**

  ```
  fields @timestamp, @message, detail  
  | filter detail.recordingStatus = "FAILED"   
  | stats count(*) as Count group by detail.agentArn as AgentArn  
  | sort by Count desc
  ```