

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

# 使用 Amazon Athena 和 Amazon QuickSight 視覺化 Amazon Redshift 稽核日誌
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight"></a>

*Sanket Sirsikar 和 Gopal Krishna Bhatia，Amazon Web Services*

## 總結
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-summary"></a>

安全性是 Amazon Web Services (AWS) 雲端上資料庫操作不可或缺的一部分。您的組織應確保監控資料庫使用者活動和連線，以偵測潛在的安全事件和風險。此模式可協助您監控資料庫以進行安全性和疑難排解，也就是稱為資料庫稽核的程序。

 此模式提供 SQL 指令碼，可自動在 Amazon QuickSight 中建立報告儀表板的 Amazon Athena 資料表和檢視，協助您稽核 Amazon Redshift 日誌。 Amazon QuickSight 這可確保負責監控資料庫活動的使用者可以方便地存取資料安全功能。 

## 先決條件和限制
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-prereqs"></a>

**先決條件**
+ 作用中的 AWS 帳戶
+ 現有的 Amazon Redshift 叢集。如需詳細資訊，請參閱 [Amazon Redshift 文件中的建立 Amazon Redshift 叢集](https://docs.aws.amazon.com/redshift/latest/dg/tutorial-loading-data-launch-cluster.html)。
+ 存取現有的 Athena 工作群組。如需詳細資訊，請參閱 Amazon Athena 文件中的[工作群組運作方式](https://docs.aws.amazon.com/athena/latest/ug/user-created-workgroups.html)。 
+ 具有必要 AWS Identity and Access Management (IAM) 許可的現有 Amazon Simple Storage Service (Amazon S3) 來源儲存貯體。如需詳細資訊，請參閱 [Amazon Redshift 文件中的資料庫稽核記錄的 Amazon Redshift 稽核記錄儲存貯體許可](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-bucket-permissions)。 [https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html)

## Architecture
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-architecture"></a>

![\[Data flow diagram showing Amazon Redshift, logs, S3 bucket, Amazon Athena, and Amazon Quick.\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/90e69009-001e-4ced-bef0-3c361f93ae87/images/9fde7f01-17ab-4207-8a59-a12daf85a382.png)


 

**技術堆疊**
+ Athena
+ Amazon Redshift 
+ Amazon S3 
+ QuickSight

## 工具
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-tools"></a>
+ [Amazon Athena](https://docs.aws.amazon.com/athena/latest/ug/what-is.html) – Athena 是一種互動式查詢服務，可讓您使用標準 SQL 輕鬆分析 Amazon S3 中的資料。 
+ [Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/welcome.html) – QuickSight 是可擴展、無伺服器、可內嵌、採用機器學習的商業智慧 (BI) 服務。 
+ [Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/gsg/getting-started.html) – Amazon Redshift 是一種企業級的 PB 級全受管資料倉儲服務。 
+ [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) – Amazon Simple Storage Service (Amazon S3) 是網際網路的儲存體。

## 史詩
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-epics"></a>

### 設定 Amazon Redshift 叢集
<a name="configure-the-amazon-redshift-cluster"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
|  啟用 Amazon Redshift 叢集的稽核記錄。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight.html) | DBA，資料工程師 | 
| 在 Amazon Redshift 叢集參數群組中啟用記錄。 | 您可以使用 AWS 管理主控台、Amazon Redshift API 參考或 AWS Command Line Interface (AWS CLI)，同時啟用連線日誌、使用者日誌和使用者活動日誌的稽核。 若要稽核使用者活動日誌，您必須啟用`enable_user_activity_logging`資料庫參數。如果您只啟用稽核記錄功能，但不啟用相關聯的參數，資料庫稽核會記錄連線和使用者日誌的記錄資訊，但不會記錄使用者活動日誌。`enable_user_activity_logging` 參數預設為未啟用，但您可以將其從 變更為 `false`來啟用它`true`。您需要在啟用 參數的情況下建立新的叢集`user_activity_logging`參數群組，並將其連接至您的 Amazon Redshift 叢集。如需詳細資訊，請參閱 Amazon Redshift 文件中的[修改叢集](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-clusters-console.html#modify-cluster)。如需此任務的詳細資訊，請參閱 [Amazon Redshift 文件中的 Amazon Redshift 參數群組](https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-parameter-groups.html)和[使用主控台設定稽核](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing-console.html)。 | DBA，資料工程師 | 
| 設定 Amazon Redshift 叢集記錄的 S3 儲存貯體許可。 | 當您啟用記錄時，Amazon Redshift 會收集記錄資訊，並將其上傳至存放在 S3 儲存貯體中的日誌檔案。您可以使用現有的 S3 儲存貯體或建立新的儲存貯體。確定 Amazon Redshift 具有存取 S3 儲存貯體所需的 IAM 許可。如需詳細資訊，請參閱 [Amazon Redshift 文件中的資料庫稽核記錄的 Amazon Redshift 稽核記錄儲存貯體許可](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-bucket-permissions)。 [https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html) | DBA，資料工程師 | 

### 建立 Athena 資料表和檢視
<a name="create-the-athena-table-and-views"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 Athena 資料表和檢視，從 S3 儲存貯體查詢 Amazon Redshift 稽核日誌資料。 | 開啟 Amazon Athena 主控台，並使用 `AuditLogging.sql` SQL 指令碼 （已連接） 的資料定義語言 (DDL) 查詢來建立使用者活動日誌、使用者日誌和連線日誌的資料表和檢視。如需詳細資訊和說明，請參閱 Amazon Athena 研討會中的[建立資料表和執行查詢](https://athena-in-action.workshop.aws/30-basics/301-create-tables.html)教學課程。 | 資料工程師 | 

### 在 QuickSight 儀表板中設定日誌監控
<a name="set-up-log-monitoring-in-the-quicksight-dashboard"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 使用 Athena 作為資料來源建立 QuickSight 儀表板。 | 開啟 Amazon QuickSight 主控台，並依照 Amazon Athena 研討會中的[使用 Athena 視覺化 QuickSight ](https://athena-in-action.workshop.aws/30-basics/307-quicksight.html)教學課程中的指示建立 QuickSight 儀表板。 | DBA，資料工程師 | 

## 相關資源
<a name="visualize-amazon-redshift-audit-logs-using-amazon-athena-and-amazon-quicksight-resources"></a>
+ [在 Athena 中建立資料表並執行查詢](https://athena-in-action.workshop.aws/30-basics/301-create-tables.html)
+ [使用 Athena 透過 QuickSight 視覺化](https://athena-in-action.workshop.aws/30-basics/307-quicksight.html)

## 附件
<a name="attachments-90e69009-001e-4ced-bef0-3c361f93ae87"></a>

若要存取與本文件相關聯的其他內容，請解壓縮下列檔案： [attachment.zip](samples/p-attach/90e69009-001e-4ced-bef0-3c361f93ae87/attachments/attachment.zip)