

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Amazon EventBridge 中監控 Amazon Redshift 資料 API 的事件
<a name="data-api-monitoring-events"></a>

EventBridge 會從您自己的應用程式、軟體即服務 (SaaS) 應用程式和 AWS 服務提供即時資料串流，因此您可以在 EventBridge 中監控資料 API 事件。EventBridge 會將該資料路由到目標，例如 AWS Lambda 和 Amazon SNS。這些事件與 CloudWatch Events 中出現的事件相同，可提供近乎即時的系統事件串流，說明 AWS 資源的變更。事件會傳送至包含 Amazon Redshift 資料庫的帳戶。例如，如果您在另一個帳戶中擔任某個角色，事件便會傳送至該帳戶。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》**中的 [Amazon EventBridge 事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html)。

當 `ExecuteStatement` 或 `BatchExecuteStatement` API 操作將 `WithEvent` 選項設定為 `true` 時，系統就會傳送資料 API 事件。事件的 `state` 欄位會包含下列其中一個值：
+ 已中止 — 使用者已停止執行查詢。
+ 失敗 — 查詢執行失敗。
+ 已完成 — 查詢已執行完成。

系統保證會提供事件。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[來自 AWS 服務的事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html)。

## 資料 API 的已完成事件範例
<a name="data-api-monitoring-events-finished"></a>

下列範例顯示當 `ExecuteStatement` API 操作完成時的資料 API 事件。在此範例中，名為 `test.testtable` 的陳述式已執行完成。

```
{
    "version": "0",
    "id": "18e7079c-dd4b-dd64-caf9-e2a31640dab0",
    "detail-type": "Redshift Data Statement Status Change",
    "source": "aws.redshift-data",
    "account": "123456789012",
    "time": "2020-10-01T21:14:26Z",
    "region": "us-east-1",
    "resources": [
        "arn:aws:redshift:us-east-1:123456789012:cluster:redshift-cluster-1"
    ],
    "detail": {
        "principal": "arn:aws:iam::123456789012:user/myuser",
        "statementName": "test.testtable",
        "statementId": "dd2e1ec9-2ee3-49a0-819f-905fa7d75a4a",
        "redshiftQueryId": -1,
        "state": "FINISHED",
        "rows": 1,
        "expireAt": 1601673265
    }
}
```