

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

# 在 Quick Sight 中使用 AWS Mainframe Modernization 和 Amazon Q 產生資料洞見
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight"></a>

*Shubham Roy、Roshna Razack 和 Santosh Kumar Singh，Amazon Web Services*

## 總結
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-summary"></a>

注意： AWS Mainframe Modernization 服務 （受管執行期環境體驗） 不再開放給新客戶。對於類似 AWS Mainframe Modernization Service （受管執行期環境體驗） 的功能，請探索 AWS Mainframe Modernization Service （自我管理體驗）。現有客戶可以繼續正常使用該服務。如需詳細資訊，請參閱[AWS Mainframe Modernization 可用性變更](https://docs.aws.amazon.com/m2/latest/userguide/mainframe-modernization-availability-change.html)。

如果您的組織在大型主機環境中託管業務關鍵資料，從該資料中獲得洞見對於推動成長和創新至關重要。透過解鎖大型主機資料，您可以建立更快、安全和可擴展的商業智慧，以加速 Amazon Web Services (AWS) 雲端中的資料驅動型決策、成長和創新。

此模式透過使用[AWS Mainframe Modernization 檔案傳輸](https://docs.aws.amazon.com/m2/latest/userguide/filetransfer.html)搭配 BMC 和 [Quick Sight 中的 Amazon Q，](https://docs.aws.amazon.com/quicksight/latest/user/quicksight-gen-bi.html)提供產生商業洞見並從大型主機資料建立可共享敘述的解決方案。大型主機資料集會使用 AWS Mainframe Modernization 檔案傳輸搭配 BMC 傳輸至 [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)。 AWS Lambda 函數會格式化和準備大型主機資料檔案，以載入 Quick Sight。

在 Quick Sight 中提供資料之後，您可以使用自然語言提示搭配 [Amazon Q](https://docs.aws.amazon.com/quicksight/latest/user/quicksight-gen-bi.html) in Quick Sight 來建立資料摘要、提出問題和產生資料案例。您不需要撰寫 SQL 查詢或學習商業智慧 (BI) 工具。

**商業內容**

此模式提供大型主機資料分析和資料洞察使用案例的解決方案。使用 模式，您可以為公司資料建置視覺化儀表板。為了示範解決方案，此模式使用提供醫療、牙科和視覺計劃給美國成員的醫療保健公司。在此範例中，成員人口統計特性和計劃資訊會存放在大型主機資料集。視覺化儀表板會顯示下列項目：
+ 區域的成員分佈
+ 依性別分配成員
+ 按年齡分配成員
+ 依計劃類型分配成員
+ 尚未完成預防性預防預防接種的成員

建立儀表板後，您會產生一個資料案例，說明先前分析的洞見。資料案例提供建議，以增加已完成預防性預防預防接種的成員人數。

## 先決條件和限制
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-prereqs"></a>

**先決條件**
+ 作用中 AWS 帳戶
+ 具有業務資料的大型主機資料集
+ 在大型主機上安裝檔案傳輸代理程式的存取權

**限制**
+ 您的大型主機資料檔案應該採用 Quick Sight 支援的其中一種檔案格式。如需支援的檔案格式清單，請參閱[支援的資料來源](https://docs.aws.amazon.com/quicksuite/latest/userguide/supported-data-sources.html)。
+ 此模式使用 Lambda 函數，將大型主機檔案轉換為 Quick Sight 支援的格式。

## Architecture
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-architecture"></a>

下圖顯示透過使用 AWS Mainframe Modernization 檔案傳輸搭配 BMC 和 Amazon Q in Quick Sight 從大型主機資料產生商業洞見的架構。

![\[架構圖描述遵循圖表。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/53572abb-06c6-4dd7-add4-8fad7e9bfa68/images/6fe0f1d9-961c-4089-a746-e5b8d5fd6c1e.png)


該圖顯示以下工作流程：

1. 包含商業資料的大型主機資料集會使用 AWS Mainframe Modernization 檔案傳輸搭配 BMC 傳輸至 Amazon S3。

1. Lambda 函數會將檔案傳輸目的地 S3 儲存貯體中的檔案轉換為逗號分隔值 (CSV) 格式。

1. Lambda 函數會將轉換後的檔案傳送至來源資料集 S3 儲存貯體。

1. Quick Sight 會擷取 檔案中的資料。

1. 使用者存取 Quick Sight 中的資料。您可以使用 Amazon Q in Quick Sight，透過自然語言提示與資料互動。

## 工具
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-tools"></a>

**AWS 服務**
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 是一項運算服務，可協助您執行程式碼，無需佈建或管理伺服器。它只會在需要時執行程式碼並自動擴展，因此您只需按使用的運算時間付費。
+ [AWS Mainframe Modernization 使用 BMC 進行檔案傳輸](https://docs.aws.amazon.com/m2/latest/userguide/filetransfer.html)會將大型主機資料集轉換和傳輸到 Amazon S3，以用於大型主機現代化、遷移和擴增使用案例。
+ [Amazon Quick Sight](https://docs.aws.amazon.com/quicksight/latest/user/welcome.html) 是一種雲端規模的 BI 服務，可協助您在單一儀表板中視覺化、分析和報告您的資料。此模式使用 [Quick Sight 中 Amazon Q 的生成式 BI ](https://docs.aws.amazon.com/quicksight/latest/user/working-with-quicksight-q.html)功能。
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。

## 最佳實務
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-best-practices"></a>
+ 當您使用 BMC 和 Lambda 函數建立 AWS Mainframe Modernization 檔案傳輸的 AWS Identity and Access Management (IAM) 角色時，請遵循[最低權限](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege)原則。
+ 確保您的來源資料集支援 [Quick Sight 的資料類型](https://docs.aws.amazon.com/quicksight/latest/user/supported-data-types-and-values.html)。如果您的來源資料集包含不支援的資料類型，請將它們轉換為支援的資料類型。如需有關不支援的大型主機資料類型以及如何將其轉換為 Amazon Q in Quick Sight 支援的資料類型的資訊，請參閱[相關資源](#generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-resources)一節。

## 史詩
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-epics"></a>

### 使用 BMC 設定 AWS Mainframe Modernization 檔案傳輸
<a name="set-up-m2long-file-transfer-with-bmc"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 安裝 檔案傳輸代理程式。 | 若要安裝 AWS Mainframe Modernization 檔案傳輸代理程式，請遵循 [AWS 文件](https://docs.aws.amazon.com/m2/latest/userguide/m2-agent-installation.html)中的指示。 | 大型主機系統管理員 | 
| 建立用於大型主機檔案傳輸的 S3 儲存貯體。 | [建立 S3 儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)體以存放使用 BMC AWS Mainframe Modernization 進行檔案傳輸的輸出檔案。在架構圖中，這是檔案傳輸目的地儲存貯體。 | 遷移工程師 | 
| 建立資料傳輸端點。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html) | AWS Mainframe Modernization 專家 | 

### 轉換大型主機檔案名稱副檔名以進行 Quick Sight 整合
<a name="convert-the-mainframe-file-name-extension-for-quick-sight-integration"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 S3 儲存貯體。 | 為 Lambda 函數[建立 S3 儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)體，將轉換後的大型主機檔案從來源複製到最終目的地儲存貯體。 | 遷移工程師 | 
| 建立 Lambda 函式。 | 若要建立 Lambda 函數來變更副檔名，並將大型主機檔案複製到目的地儲存貯體，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html) | 遷移工程師 | 
| 建立 Amazon S3 觸發程序來叫用 Lambda 函數。 | 若要設定叫用 Lambda 函數的觸發，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html)如需詳細資訊，請參閱[教學課程：使用 Amazon S3 觸發條件叫用 Lambda 函數](https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html)。 | 遷移潛在客戶 | 
| 提供 Lambda 函數的 IAM 許可。 | Lambda 函數需要 IAM 許可才能存取檔案傳輸目的地和來源資料集 S3 儲存貯體。透過允許檔案傳輸目的地 S3 儲存貯** **體的 `s3:GetObject` 和 `s3:DeleteObject`** **許可，以及來源資料集 S3 儲存貯體的 `s3:PutObject` 存取，更新與 Lambda 函數執行角色相關聯的政策。如需詳細資訊，請參閱*教學課程：使用 Amazon S3 觸發來叫用 Lambda 函數*中的[建立許可政策](https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html#with-s3-example-create-policy)** **一節。 | 遷移潛在客戶 | 

### 定義大型主機資料傳輸任務
<a name="define-a-mainframe-data-transfer-task"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立傳輸任務，將大型主機檔案複製到 S3 儲存貯體。 | 若要建立大型主機檔案傳輸任務，請遵循 [AWS Mainframe Modernization 文件中的指示。](https://docs.aws.amazon.com/m2/latest/userguide/filetransfer-transfer-tasks.html)將**來源碼頁面**編碼指定為 **IBM1047**，並將**目標碼頁面**編碼指定為** UTF-8**。 | 遷移工程師 | 
| 驗證傳輸任務。 | 若要驗證資料傳輸是否成功，請遵循 [AWS Mainframe Modernization 文件](https://docs.aws.amazon.com/m2/latest/userguide/filetransfer-transfer-tasks.html#filetransfer-ts-view-console)中的指示。確認大型主機檔案位於檔案傳輸目的地 S3 儲存貯體中。 | 遷移潛在客戶 | 
| 驗證 Lambda 複製函數。 | 確認 Lambda 函數已啟動，且檔案已使用 .csv 副檔名複製到來源資料集 S3 儲存貯體。Lambda 函數建立的 .csv 檔案是 Quick Sight 的輸入資料檔案。如需範例資料，請參閱[附件](#attachments-53572abb-06c6-4dd7-add4-8fad7e9bfa68)區段中的 `Sample-data-member-healthcare-APG` 檔案。 | 遷移潛在客戶 | 

### 將 Quick Sight 連線至大型主機資料
<a name="connect-quick-sight-to-the-mainframe-data"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定 Quick Sight。 | 若要設定 Quick Sight，請遵循 [AWS 文件](https://docs.aws.amazon.com/quicksight/latest/user/setting-up.html)中的指示。 | 遷移潛在客戶 | 
| 建立 Quick Sight 的資料集。 | 若要建立 Quick Sight 的資料集，請遵循 [AWS 文件](https://docs.aws.amazon.com/quicksight/latest/user/create-a-data-set-s3.html)中的指示。輸入資料檔案是在您定義大型主機資料傳輸任務時建立的轉換大型主機檔案。 | 遷移潛在客戶 | 

### 使用 Quick Sight 中的 Amazon Q 從大型主機資料中取得商業洞見
<a name="get-business-insights-from-the-mainframe-data-by-using-qdev-in-quick-sight"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在 Quick Sight 中設定 Amazon Q。 | 此功能需要 Enterprise Edition。若要在 Quick Sight 中設定 Amazon Q，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html) | 遷移潛在客戶 | 
| 分析大型主機資料並建置視覺化儀表板。 | 若要在 Quick Sight 中分析和視覺化您的資料，請執行下列動作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html)完成後，您可以發佈儀表板，與組織中的其他人共用。如需範例，請參閱[其他資訊](#generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-additional)區段中的*大型主機視覺化儀表板*。 | 遷移工程師 | 

### 從大型主機資料使用 Quick Sight 中的 Amazon Q 建立資料案例
<a name="create-a-data-story-with-qdev-in-quick-sight-from-the-mainframe-data"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立資料案例。 | 建立資料案例來解釋先前分析的洞見，並產生建議，以增加成員的預防性預防預防接種：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html) | 遷移工程師 | 
| 檢視產生的資料案例。 | 若要檢視產生的資料案例，請遵循 [AWS 文件](https://docs.aws.amazon.com/quicksight/latest/user/working-with-stories-view.html)中的指示。 | 遷移潛在客戶 | 
| 編輯產生的資料案例。 | 若要變更資料案例中的格式、配置或視覺效果，請遵循[AWS 文件中](https://docs.aws.amazon.com/quicksight/latest/user/working-with-stories-edit.html)的指示。 | 遷移潛在客戶 | 
| 分享資料案例。 | 若要分享資料案例，請遵循[AWS 文件中](https://docs.aws.amazon.com/quicksight/latest/user/working-with-stories-share.html)的指示。 | 遷移工程師 | 

## 疑難排解
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 無法探索在**資料集搜尋條件**中輸入的大型主機檔案或資料集，以使用 BMC 在 AWS Mainframe Modernization 檔案**傳輸中建立傳輸任務**。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight.html) | 

## 相關資源
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-resources"></a>

若要將 [PACKED-DECIMAL (COMP-3)](https://www.ibm.com/docs/en/cobol-zos/6.3?topic=v6-packed-decimal-comp-3) 或 [BINARY (COMP 或 COMP-4)](https://www.ibm.com/docs/en/cobol-zos/6.3?topic=v6-binary-comp-comp-4) 等大型主機資料類型轉換為 Quick Sight 支援的[資料類型](https://docs.aws.amazon.com/quicksight/latest/user/supported-data-types-and-values.html)，請參閱下列模式：
+ [AWS 使用 Python 將 EBCDIC 資料轉換為 上的 ASCII](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/convert-and-unpack-ebcdic-data-to-ascii-on-aws-by-using-python.html)
+ [使用 在 Amazon S3 中將大型主機檔案從 EBCDIC 格式轉換為字元分隔 ASCII 格式 AWS Lambda](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/convert-mainframe-files-from-ebcdic-format-to-character-delimited-ascii-format-in-amazon-s3-using-aws-lambda.html)

## 其他資訊
<a name="generate-data-insights-by-using-aws-mainframe-modernization-and-amazon-q-in-quicksight-additional"></a>

**S3CopyLambda.py**

下列 Python 程式碼是透過在 IDE 中使用 Amazon Q 的提示產生：

```
#Create a lambda function triggered by S3. display the S3 bucket name and key
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context):
print(event)
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
print(bucket, key)
#If key starts with object_created, skip copy, print "copy skipped". Return lambda with key value.
if key.startswith('object_created'):
print("copy skipped")
return {
'statusCode': 200,
'body': key
}
# Copy the file from the source bucket to the destination bucket. Destination_bucket_name = 'm2-filetransfer-final-opt-bkt'. Destination_file_key = 'healthdata.csv'
copy_source = {'Bucket': bucket, 'Key': key}
s3.copy_object(Bucket='m2-filetransfer-final-opt-bkt', Key='healthdata.csv', CopySource=copy_source)
print("file copied")
#Delete the file from the source bucket.
s3.delete_object(Bucket=bucket, Key=key)
return {
'statusCode': 200,
'body': 'Copy Successful'
}
```

**大型主機視覺化儀表板**

下列資料視覺效果是由 Amazon Q in Quick Sight 為分析問題 所建立`show member distribution by region`*。*

![\[圖表顯示西南部、中西部、東北部和東南部的成員數量。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/53572abb-06c6-4dd7-add4-8fad7e9bfa68/images/e5c1d049-407d-42ff-bc51-28f9d2b24d4f.png)


以下資料視覺效果是由 Amazon Q in Quick Sight 為問題 建立`show member distribution by Region who have not completed preventive immunization, in pie chart`。

![\[Pie chart showing preventive immunization incompletion by region: Southeast 40%, Southwest 33%, Midwest 27%.\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/53572abb-06c6-4dd7-add4-8fad7e9bfa68/images/47efa1c1-54c9-47cc-b668-416090021d34.png)


**資料案例輸出**

下列螢幕擷取畫面顯示 Amazon Q in Quick Sight 建立的資料案例區段提示 `Build a data story about Region with most numbers of members. Also show the member distribution by medical plan, vision plan, dental plan. Recommend how to motivate members to complete immunization. Include 4 points of supporting data.`

在簡介中，資料案例建議選擇最多成員的區域，以從防制措施中獲得最大的影響。

![\[著重於預防接種完成率的資料案例簡介頁面。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/53572abb-06c6-4dd7-add4-8fad7e9bfa68/images/4612fcc7-51fd-48a5-bc58-b6b0aa9b0ef3.png)


資料案例提供前三個區域的成員號碼分析，並將西南地區命名為專注於防制措施的領導區域。

![\[Pie chart showing member distribution by region, with Southwest and Northeast leading at 31% each.\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/53572abb-06c6-4dd7-add4-8fad7e9bfa68/images/30d3b56b-3b92-4748-9cef-a73ff9339fee.png)


**注意**  
西南部和東北部各有八個成員。不過，西南部有更多成員未完全進行預防，因此更有可能受益於提高預防接種率的計劃。

## 附件
<a name="attachments-53572abb-06c6-4dd7-add4-8fad7e9bfa68"></a>

若要存取與本文件相關聯的其他內容，請解壓縮下列檔案： [attachment.zip](samples/p-attach/53572abb-06c6-4dd7-add4-8fad7e9bfa68/attachments/attachment.zip)