本指南說明如何設定 Google Cloud的 Agent for SAP,以便從 SAP 系統收集 Process Monitoring 指標。
如要瞭解這項功能,請參閱「使用 Google Cloud的 SAP 代理程式進行程序監控」。
事前準備
- 驗證 Google Cloud的 Agent for SAP 安裝作業。如需操作說明,請參閱適用於您情況的安裝指南。
- 如果您已在 Bare Metal 解決方案伺服器上安裝代理程式,請確認您已完成必要的先決條件,並設定服務帳戶。如需操作說明,請參閱「在 Linux 上設定 Google Cloud的 Agent for SAP」。
必要的 IAM 角色
為確保服務帳戶具備必要權限,讓 Google Cloud的 SAP 代理程式收集 Process Monitoring 指標,請要求管理員將下列 IAM 角色授予服務帳戶:
-
Compute 檢視器 (
roles/compute.viewer
): 從代管 SAP 系統的 Compute Engine 執行個體收集 Process Monitoring 指標。 -
Monitoring 指標寫入者 (
roles/monitoring.metricWriter
): 將收集到的指標寫入 Cloud Monitoring。 -
(選用) Secret Manager 密鑰存取者 (
roles/secretmanager.secretAccessor
):如果您使用 Secret Manager 儲存密碼,以便連線至 SAP HANA 資料庫。
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這些預先定義的角色具備 Google Cloud的 SAP 服務代理收集 Process Monitoring 指標所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要讓 Google Cloud的 SAP 代理程式收集 Process Monitoring 指標,必須具備下列權限:
-
如要從主機 Compute Engine 執行個體收集 Process Monitoring 指標,並將指標寫入 Cloud Monitoring,請按照下列步驟操作:
-
monitoring.timeSeries.create
-
compute.instances.get
-
compute.nodeGroups.list
-
compute.nodeGroups.get
-
-
如果您使用 Secret Manager 儲存密碼來連線至 SAP HANA 資料庫,請按照下列步驟存取密鑰:
secretmanager.versions.access
您的管理員也可能會透過自訂角色或其他預先定義的角色,將這些權限授予服務帳戶。
必要的 SAP HANA 角色
如要讓代理程式從 SAP HANA 資料庫收集指標,請確認您在代理程式設定檔中指定的 SAP HANA 使用者具有 MONITORING
角色。
如要瞭解這個角色,請參閱 SAP 文件「標準資料庫角色」。
啟用 Process Monitoring 指標收集功能
如要啟用使用Google Cloud適用於 SAP 的代理程式收集程序監控指標的功能,請按照下列步驟操作:
與主機 Compute Engine 執行個體建立 SSH 連線。
開啟代理程式的設定檔:
/etc/google-cloud-sap-agent/configuration.json
或者,您也可以執行指令來執行這項設定。詳情請參閱「 Google Cloud的 SAP 代理程式設定指令」。
在
collection_configuration
部分中,執行以下操作:- 針對參數
collect_process_metrics
,指定true
值。 - 如要啟用與 SAP HANA 資料庫執行個體相關的程序監控指標收集功能,您必須在
hana_metrics_config
專區中設定額外參數。如要瞭解這些參數,請參閱「設定參數」。
- 針對參數
您可以選擇在
cloud_properties
部分下方更新自動設定的參數值。如要這樣做,請在設定檔中新增cloud_properties
部分,然後指定必要參數及其值。儲存設定檔。
重新啟動代理程式,讓新設定生效:
sudo systemctl restart google-cloud-sap-agent
設定檔範例
Compute Engine 執行個體
以下範例是Google Cloud的 SAP 代理程式設定檔,在Compute Engine 執行個體上執行,並啟用 Process Monitoring 指標的收集功能:
針對 SAP HANA 驗證,代理程式會使用下列優先順序:如果已指定,hdbuserstore_key
設定參數會優先於 hana_db_password
參數,而 hana_db_password
參數會優先於 hana_db_password_secret_name
參數。建議您在設定檔中只設定一個驗證選項。
- 以下範例使用 安全使用者儲存庫 (
hdbuserstore
) 金鑰進行 SAP HANA 驗證:{ "provide_sap_host_agent_metrics": true, "bare_metal": false, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hdbuserstore_key": "user_store_key" } }, "discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } }
- 以下範例使用使用者名稱和 Secret Manager 密鑰進行 SAP HANA 驗證:
{ "provide_sap_host_agent_metrics": true, "bare_metal": false, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hana_db_password_secret_name": "db_pwd_secret_name" } }, "discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } }
- 以下範例使用使用者名稱和密碼進行 SAP HANA 驗證。建議您改為使用 Secret Manager 密鑰或安全使用者儲存庫 (
hdbuserstore
) 金鑰進行 SAP HANA 驗證。{ "provide_sap_host_agent_metrics": true, "bare_metal": false, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hana_db_password": "TempPa55word" } }, "discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } }
Bare Metal 解決方案伺服器
以下範例是Google Cloud的 SAP 代理程式設定檔,在Bare Metal Solution 伺服器上執行,並啟用 Process Monitoring 指標收集功能:
針對 SAP HANA 驗證,代理程式會使用下列優先順序:如果已指定,hdbuserstore_key
設定參數會優先於 hana_db_password
參數,而 hana_db_password
參數會優先於 hana_db_password_secret_name
參數。建議您在設定檔中只設定一個驗證選項。
- 以下範例使用 安全使用者儲存庫 (
hdbuserstore
) 金鑰進行 SAP HANA 驗證:{ "provide_sap_host_agent_metrics": true, "bare_metal": true, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hdbuserstore_key": "user_store_key" } }, "cloud_properties": { "project_id": "my-project", "instance_name": "bms-machine-1", "region": "us-central1", "image": "rhel-8" },
"discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } } - 以下範例使用使用者名稱和 Secret Manager 密鑰進行 SAP HANA 驗證:
{ "provide_sap_host_agent_metrics": true, "bare_metal": true, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hana_db_password_secret_name": "db_pwd_secret_name" } }, "cloud_properties": { "project_id": "my-project", "instance_name": "bms-machine-1", "region": "us-central1", "image": "rhel-8" },
"discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } } - 以下範例使用使用者名稱和密碼進行 SAP HANA 驗證。建議您改為使用 Secret Manager 密鑰或安全使用者儲存庫 (
hdbuserstore
) 金鑰進行 SAP HANA 驗證。{ "provide_sap_host_agent_metrics": true, "bare_metal": true, "log_level": "INFO", "log_to_cloud": true, "collection_configuration": { "collect_workload_validation_metrics": true, "collect_process_metrics": true, "process_metrics_frequency": 5, "slow_process_metrics_frequency": 30, "hana_metrics_config": { "hana_db_user": "db_user_name", "sid": "DEH", "hana_db_password": "TempPa55word" } }, "cloud_properties": { "project_id": "my-project", "instance_name": "bms-machine-1", "region": "us-central1", "image": "rhel-8" },
"discovery_configuration": { "enable_discovery": true, "enable_workload_discovery": true }, "hana_monitoring_configuration": { "enabled": false } }
設定參數
下表說明Google Cloud的 SAP 專用代理程式設定參數,這些參數與程序監控指標的收集作業相關。
參數 | |
---|---|
provide_sap_host_agent_metrics |
如要啟用 SAP Host Agent 所需的指標收集功能,請指定 |
bare_metal |
將代理程式安裝在 Bare Metal 解決方案伺服器上時,請指定 |
log_level |
如要設定代理程式的記錄等級,請設定必要值。可用的記錄層級如下:
預設為 |
log_to_cloud |
如要將代理程式的記錄重新導向至 Cloud Logging,請指定 |
cloud_properties.project_id |
如果您的 SAP 系統是在 Bare Metal 解決方案伺服器上執行,請指定您在 Bare Metal 解決方案中使用的 Google Cloud 專案 ID。 |
cloud_properties.instance_name
|
如果您的 SAP 系統是在 Compute Engine 執行個體上執行,請指定該 Compute Engine 執行個體的名稱。代理程式會在安裝時自動偵測運算執行個體名稱。 如果 SAP 系統是在 Bare Metal Solution 伺服器上執行,請指定該伺服器的名稱。 |
cloud_properties.region |
如果 SAP 系統是在 Bare Metal 解決方案伺服器上執行,請指定 Bare Metal 解決方案伺服器的區域。 |
cloud_properties.zone |
當代理在運算執行個體上執行時,根據預設,代理會使用運算執行個體部署所在的區域。 |
cloud_properties.image |
指定執行個體的 OS 映像檔名稱。 |
cloud_properties.numeric_project_id |
指定執行 SAP 系統的 Google Cloud 專案的數字 ID。 |
discovery_configuration.enable_workload_discovery |
如要讓代理程式收集主機上執行的 SAP 產品名稱和版本,請指定 詳情請參閱 |
discovery_configuration.enable_discovery |
如要將代理程式收集到的關於主機上執行的 SAP 產品資訊傳送至 Cloud Logging,請指定 如果您指定 |
collection_configuration.collect_process_metrics |
如要啟用 Process Monitoring 指標收集功能,請指定 |
collection_configuration.process_metrics_frequency |
自 2.6 版起,這個參數會以秒為單位,決定快速變動的程序監控指標的收集頻率。變化快速的 Process Monitoring 指標為: 這個參數的預設值為 所有其他 (變動緩慢) 的 Process Monitoring 指標,會以 30 秒的預設頻率收集。如要變更變化緩慢的 Process Monitoring 指標的收集頻率,請使用 |
collection_configuration.slow_process_metrics_frequency |
指定變動緩慢的程序監控指標的收集頻率 (以秒為單位)。 這個參數的預設值為 |
collection_configuration.process_metrics_to_skip |
指定不想讓代理程式收集的Process Monitoring 指標。這個參數接受以逗號分隔的 Process Monitoring 指標名稱值。例如: |
collection_configuration.hana_metrics_config.hana_db_user |
指定代理程式用來查詢 SAP HANA 的資料庫使用者帳戶。預設值為 |
collection_configuration.hana_metrics_config.hana_db_password |
為資料庫使用者帳戶指定純文字密碼,代理程式會使用這組密碼查詢 SAP HANA。 建議您改用下列任一選項,而非指定純文字密碼:
針對 SAP HANA 驗證,代理程式會使用下列優先順序:如果已指定, |
collection_configuration.hana_metrics_config.hana_db_password_secret_name |
如要安全地提供資料庫使用者帳戶的密碼,以便代理程式用於查詢 SAP HANA,請指定包含資料庫使用者帳戶安全性憑證的機密資料名稱。 只有在您指定 針對 SAP HANA 驗證,代理程式會使用下列優先順序:如果已指定, |
collection_configuration.hana_metrics_config.hdbuserstore_key
|
如要安全地連線至 SAP HANA 系統,請指定您為該系統建立的 安全使用者儲存庫 ( 如要使用
這個設定參數自 3.3 版開始支援。 針對 SAP HANA 驗證,代理程式會使用下列優先順序:如果已指定, |
collection_configuration.hana_metrics_config.sid |
指定 SAP HANA 執行個體的 SID。
如果您使用 |
驗證程序監控指標收集設定
您可以執行代理程式的 status
指令,驗證是否已正確 Google Cloud 設定程序監控指標的收集作業。這個指令自 3.7 版代理程式起即受支援。
如要這樣做,請按照下列步驟進行:
- 與 Compute Engine 執行個體或 Bare Metal 解決方案伺服器建立 SSH 連線。
執行下列指令:
sudo /usr/bin/google_cloud_sap_agent status
如果您 Google Cloud 設定的程序監控指標收集作業正確無誤,輸出內容就會包含下列項目。您的設定可能包含
default
以外的值。Agent Status: ... Systemd Service Enabled: True Systemd Service Running: True Cloud API Full Scopes: True Configuration File: /etc/google-cloud-sap-agent/configuration.json Configuration Valid: True ... ---------------------------------------------------------------------------- Process Metrics: Enabled Status: Fully Functional IAM Permissions: All granted Configuration: collect_process_metrics: true (configuration file) process_metrics_frequency: 5 (default) process_metrics_to_skip: [] (default) slow_process_metrics_frequency: 30 (default) ...
如果輸出內容顯示缺少部分設定,請查看前面各節提供的資訊,執行必要動作,然後重新執行
status
指令,重新驗證設定。
查看收集的指標
如要以視覺化方式呈現代理程式收集的Process Monitoring 指標,您可以使用Google Cloud 提供的下列自訂資訊主頁:
SAP 專用代理程式 - HANA 總覽:此資訊主頁提供圖表,顯示下列指標的狀態總覽:SAP HANA 可用性、SAP HANA HA 可用性、SAP HANA HA 複製、SAP HANA 服務狀態、HA 叢集 - 節點狀態,以及 HA 叢集 - SAP 執行個體的資源狀態。
這個資訊主頁的 JSON 檔案為
sap-agent-status-overview.json
。SAP 專用代理程式 - HANA 原始指標:這個資訊主頁提供圖表,顯示下列指標的原始指標值:SAP HANA 可用性、SAP HANA HA 可用性、SAP HANA HA 複寫、SAP HANA 服務狀態、HA 叢集 - 節點狀態,以及 HA 叢集 - SAP 執行個體的資源狀態。
這個資訊主頁的 JSON 檔案為
sap-agent-raw-metrics.json
。
安裝資訊主頁
如要安裝自訂資訊主頁,請完成下列步驟:
Google Cloud 控制台
在 Google Cloud 控制台中,前往「Monitoring」頁面:
在「Monitoring」導覽面板中,按一下「Dashboards」。
按一下「Sample library」分頁標籤。
如要篩選特定服務專員的自訂資訊主頁,請在「Filter」欄位中輸入
Agent for SAP
。(選用) 如要查看資訊主頁的詳細資料或預覽內容,請按一下「預覽」。
選取要安裝的資訊主頁。
依序點選「匯入」和「確認」。
資訊主頁會新增至Google Cloud 專案中可用的資訊主頁。如要查看資訊主頁,請按照「查看已安裝的資訊主頁」中的操作說明進行。
Google Cloud CLI
開啟 Cloud Shell:
在 Cloud Shell 中,複製或下載存放區:
git clone https://github.com/GoogleCloudPlatform/monitoring-dashboard-samples/
在 Cloud Shell 中,使用對應的 JSON 檔案安裝必要的資訊主頁:
gcloud monitoring dashboards create --config-from-file=CONFIG_FROM_FILE
將
CONFIG_FROM_FILE
替換為指向含有資訊主頁設定的 JSON 檔案路徑。資訊主頁設定檔位於路徑:monitoring-dashboard-samples/dashboards/google-cloud-agent-for-sap
。資訊主頁會新增至 Google Cloud 專案中可用的資訊主頁。如要查看資訊主頁,請按照「查看已安裝的資訊主頁」中的指示操作。
查看已安裝的資訊主頁
如要查看已安裝的資訊主頁,請按照下列步驟操作:
在 Google Cloud 控制台中,前往「Monitoring」頁面:
在「Monitoring」導覽面板中,按一下「Dashboards」。
按一下清單中的資訊主頁名稱。
如果您有許多資訊主頁,可以篩選自訂資訊主頁或新資訊主頁的名稱。如要進一步瞭解如何篩選這份名單,請參閱「查看自訂資訊主頁」一文。
以下圖片為範例,顯示 Monitoring 中 SAP HANA 指標的自訂資訊主頁部分。