SAP HANA

SAP HANA 整合服務會收集 SAP HANA 指標和記錄。系統會查詢相關監控檢視畫面,藉此收集指標。這項整合功能會寫入結構化追蹤記錄檔。

如要進一步瞭解 HANA,請參閱 SAP HANA 說明文件

必要條件

如要收集 HANA 遙測資料,請安裝 Ops Agent

  • 如要使用指標,請安裝 2.18.1 以上版本。
  • 如要查看記錄,請安裝 2.18.1 以上版本。

這項整合功能支援 HANA 2.0 版。

設定 HANA 執行個體

如要收集指標,監控使用者必須具備相關監控檢視的 SELECT 存取權。如果使用者連線至 SAP HANA 執行個體時具備足夠權限,執行下列 SQL 指令碼即可建立監控角色,並套用至監控使用者。

--Create the user
CREATE RESTRICTED USER otel_monitoring_user PASSWORD ;
--Enable user login
ALTER USER otel_monitoring_user ENABLE CLIENT CONNECT;
--Create the monitoring role
CREATE ROLE OTEL_MONITORING;
--Grant permissions to the relevant views
GRANT CATALOG READ TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_BACKUP_CATALOG TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_BLOCKED_TRANSACTIONS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_CONNECTIONS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_CS_ALL_COLUMNS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_CS_TABLES TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_DATABASE TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_DISKS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_HOST_RESOURCE_UTILIZATION TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_LICENSES TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_RS_TABLES TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICE_COMPONENT_MEMORY TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICE_MEMORY TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICE_REPLICATION TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICE_STATISTICS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICE_THREADS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_SERVICES TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_VOLUME_IO_TOTAL_STATISTICS TO OTEL_MONITORING;
GRANT SELECT ON SYS.M_WORKLOAD TO OTEL_MONITORING;
GRANT SELECT ON _SYS_STATISTICS.STATISTICS_CURRENT_ALERTS TO OTEL_MONITORING;
GRANT SELECT ON DUMMY TO OTEL_MONITORING;
--Add the OTEL_MONITOR role to the monitoring user
GRANT OTEL_MONITORING TO otel_monitoring_user;

設定 HANA 的作業套件代理程式

按照「設定作業套件代理程式」指南操作,新增必要元素,從 HANA 執行個體收集遙測資料,然後重新啟動代理程式

範例設定

下列指令會建立設定,以收集及擷取 HANA 的遙測資料:

# Configures Ops Agent to collect telemetry from the app. You must restart the agent for the configuration to take effect.

set -e

# Check if the file exists
if [ ! -f /etc/google-cloud-ops-agent/config.yaml ]; then
  # Create the file if it doesn't exist.
  sudo mkdir -p /etc/google-cloud-ops-agent
  sudo touch /etc/google-cloud-ops-agent/config.yaml
fi

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
logging:
  receivers:
    saphana:
      type: saphana
      include_paths:
      - /usr/sap/*/HDB*/*/trace/*.trc
      exclude_paths:
      - /usr/sap/*/HDB*/*/trace/nameserver_history*.trc
      - /usr/sap/*/HDB*/*/trace/nameserver*loads*.trc
      - /usr/sap/*/HDB*/*/trace/nameserver*executed_statements*.trc
  service:
    pipelines:
      saphana:
        receivers:
          - saphana
metrics:
  receivers:
    saphana:
      type: saphana
      username: SYSTEM
      password: G00g3l21
      # To use the googlesecretmanager provider to replace plaintext passwords, refer to the example below.
      # password: ${googlesecretmanager:projects/<project-id>/secrets/<secret-id>/versions/<version-id>}
      endpoint: localhost:30015
  service:
    pipelines:
      saphana:
        receivers:
          - saphana
EOF

如要讓這些變更生效,請重新啟動 Ops Agent:

Linux

  1. 如要重新啟動代理程式,請在執行個體上執行下列指令:
    sudo systemctl restart google-cloud-ops-agent
    
  2. 如要確定代理程式已重新啟動,請執行下列指令,並驗證「指標代理程式」和「Logging 代理程式」元件是否已啟動:
    sudo systemctl status "google-cloud-ops-agent*"
    

Windows

  1. 使用遠端桌面協定或類似工具連線至執行個體,並登入 Windows。
  2. 以滑鼠右鍵按一下 PowerShell 圖示,然後選取「以系統管理員身分執行」,以管理員權限開啟 PowerShell 終端機。
  3. 如要重新啟動代理程式,請執行下列 PowerShell 指令:
    Restart-Service google-cloud-ops-agent -Force
    
  4. 如要確定代理程式已重新啟動,請執行下列指令,並驗證「指標代理程式」和「Logging 代理程式」元件是否已啟動:
    Get-Service google-cloud-ops-agent*
    

設定記錄檔收集作業

如要從 HANA 擷取記錄,您必須為 HANA 產生的記錄建立接收器,然後為新的接收器建立管道。

如要設定 saphana 記錄的接收器,請指定下列欄位:

欄位 預設 說明
exclude_paths [/usr/sap/*/HDB*/${HOSTNAME}/trace/nameserver_history*.trc, /usr/sap/*/HDB*/${HOSTNAME}/trace/nameserver*loads*.trc, /usr/sap/*/HDB*/${HOSTNAME}/trace/nameserver*executed_statements*.trc] 要從 include_paths 比對的集合中排除的檔案系統路徑模式清單。
include_paths [/usr/sap/*/HDB*/${HOSTNAME}/trace/*.trc] 要讀取的檔案系統路徑清單,方法是追蹤每個檔案。路徑中可以使用萬用字元 (*)。
record_log_file_path false 如果設為 true,輸出記錄項目中就會顯示路徑,指出記錄項目是從哪個特定檔案取得,並做為 agent.googleapis.com/log_file_path 標籤的值。使用萬用字元時,系統只會記錄取得記錄的檔案路徑。
type 此值必須是 saphana
wildcard_refresh_interval 60s include_paths 中萬用字元檔案路徑的重新整理間隔。以時間長度表示,例如 30s2m。在記錄吞吐量較高的情況下,記錄檔的輪替速度會比預設間隔更快,這時這個屬性就可能派上用場。

記錄內容

logName 是從設定中指定的接收器 ID 衍生而來。LogEntry 內的詳細欄位如下。

saphana 記錄包含 LogEntry 中的下列欄位:

欄位 類型 說明
jsonPayload.component 字串 SAP HANA 元件
jsonPayload.connection_id 數字 如果訊息是在連線範圍內記錄,則為訊息來源連線的 ID
jsonPayload.message 字串 記錄訊息
jsonPayload.severity_flag 字串 記錄項目層級
jsonPayload.thread_id 數字 記錄訊息的執行緒 ID
jsonPayload.transaction_id 數字 如果訊息是在交易範圍內記錄,則為訊息來源交易的 ID
jsonPayload.update_transaction_id 數字 如果訊息是在更新交易的範圍內記錄,則為訊息來源的更新交易 ID
severity 字串 (LogSeverity) 記錄項目層級 (已翻譯)。
sourceLocation.file 字串 來源檔案名稱
sourceLocation.line 數字 來源檔案中的行

設定指標收集

如要從 HANA 擷取指標,您必須為 HANA 產生的指標建立接收器,然後為新的接收器建立管道。

這個接收器不支援在設定中使用多個執行個體,例如監控多個端點。所有這類執行個體都會寫入相同的時間序列,而 Cloud Monitoring 無法區分這些執行個體。

如要為 saphana 指標設定接收器,請指定下列欄位:

欄位 預設 說明
ca_file CA 憑證的路徑。做為用戶端,這會驗證伺服器憑證。如果為空白,接收器會使用系統根 CA。
cert_file 用於 mTLS 必要連線的 TLS 憑證路徑。
collection_interval 60s 時間長度值,例如 30s5m
endpoint localhost:30015 用於連線至 SAP HANA 執行個體的 hostname:port
insecure true 設定是否使用安全的 TLS 連線。如果設為 false,系統會啟用 TLS。
insecure_skip_verify false 設定是否要略過驗證憑證。如果 insecure 設為 true,系統就不會使用 insecure_skip_verify 值。
key_file 用於 mTLS 必要連線的 TLS 金鑰路徑。
password 用於連線至執行個體的密碼。
type 這個值必須是 saphana
username 用於連線至執行個體的使用者名稱。

監控的內容

下表列出作業套件代理程式從 HANA 執行個體收集的指標。

指標類型
類型
受監控資源
標籤
workload.googleapis.com/saphana.alert.count
GAUGEINT64
gce_instance
rating
workload.googleapis.com/saphana.backup.latest
GAUGEINT64
gce_instance
 
workload.googleapis.com/saphana.column.memory.used
GAUGEINT64
gce_instance
host
subtype
type
workload.googleapis.com/saphana.component.memory.used
GAUGEINT64
gce_instance
component
host
workload.googleapis.com/saphana.connection.count
GAUGEINT64
gce_instance
host
status
workload.googleapis.com/saphana.cpu.used
CUMULATIVEINT64
gce_instance
host
type
workload.googleapis.com/saphana.disk.size.current
GAUGEINT64
gce_instance
host
path
state
usage_type
workload.googleapis.com/saphana.host.memory.current
GAUGEINT64
gce_instance
host
state
workload.googleapis.com/saphana.host.swap.current
GAUGEINT64
gce_instance
host
state
workload.googleapis.com/saphana.instance.code_size
GAUGEINT64
gce_instance
host
workload.googleapis.com/saphana.instance.memory.current
GAUGEINT64
gce_instance
host
state
workload.googleapis.com/saphana.instance.memory.shared.allocated
GAUGEINT64
gce_instance
host
workload.googleapis.com/saphana.instance.memory.used.peak
GAUGEINT64
gce_instance
host
workload.googleapis.com/saphana.license.expiration.time
GAUGEINT64
gce_instance
product
system
workload.googleapis.com/saphana.license.limit
GAUGEINT64
gce_instance
product
system
workload.googleapis.com/saphana.license.peak
GAUGEINT64
gce_instance
product
system
workload.googleapis.com/saphana.network.request.average_time
GAUGEDOUBLE
gce_instance
host
workload.googleapis.com/saphana.network.request.count
GAUGEINT64
gce_instance
host
state
workload.googleapis.com/saphana.network.request.finished.count
CUMULATIVEINT64
gce_instance
host
type
workload.googleapis.com/saphana.replication.average_time
GAUGEDOUBLE
gce_instance
mode
port
primary
secondary
workload.googleapis.com/saphana.replication.backlog.size
GAUGEINT64
gce_instance
mode
port
primary
secondary
workload.googleapis.com/saphana.replication.backlog.time
GAUGEINT64
gce_instance
mode
port
primary
secondary
workload.googleapis.com/saphana.row_store.memory.used
GAUGEINT64
gce_instance
host
type
workload.googleapis.com/saphana.schema.memory.used.current
GAUGEINT64
gce_instance
host
schema
type
workload.googleapis.com/saphana.schema.memory.used.max
GAUGEINT64
gce_instance
host
schema
workload.googleapis.com/saphana.schema.operation.count
CUMULATIVEINT64
gce_instance
host
schema
type
workload.googleapis.com/saphana.schema.record.compressed.count
GAUGEINT64
gce_instance
host
schema
workload.googleapis.com/saphana.schema.record.count
GAUGEINT64
gce_instance
host
schema
type
workload.googleapis.com/saphana.service.code_size
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.count
GAUGEINT64
gce_instance
host
status
workload.googleapis.com/saphana.service.memory.compactors.allocated
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.memory.compactors.freeable
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.memory.effective_limit
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.memory.heap.current
GAUGEINT64
gce_instance
host
service
state
workload.googleapis.com/saphana.service.memory.limit
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.memory.shared.current
GAUGEINT64
gce_instance
host
service
state
workload.googleapis.com/saphana.service.memory.used
GAUGEINT64
gce_instance
host
service
type
workload.googleapis.com/saphana.service.stack_size
GAUGEINT64
gce_instance
host
service
workload.googleapis.com/saphana.service.thread.count
GAUGEINT64
gce_instance
host
status
workload.googleapis.com/saphana.transaction.blocked
GAUGEINT64
gce_instance
host
workload.googleapis.com/saphana.transaction.count
CUMULATIVEINT64
gce_instance
host
type
workload.googleapis.com/saphana.volume.operation.count
CUMULATIVEINT64
gce_instance
host
path
type
usage_type
workload.googleapis.com/saphana.volume.operation.size
CUMULATIVEINT64
gce_instance
host
path
type
usage_type
workload.googleapis.com/saphana.volume.operation.time
CUMULATIVEINT64
gce_instance
host
path
type
usage_type

驗證設定

本節說明如何確認您已正確設定 HANA 接收器。作業套件代理程式可能需要一到兩分鐘,才會開始收集遙測資料。

如要確認 HANA 記錄是否已傳送至 Cloud Logging,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的「Logs Explorer」頁面:

    前往「Logs Explorer」(記錄檔探索工具)

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Logging」的結果

  2. 在編輯器中輸入下列查詢,然後按一下「執行查詢」
    resource.type="gce_instance"
    log_id("saphana")
    

如要確認 HANA 指標是否已傳送至 Cloud Monitoring,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 「Metrics Explorer」頁面:

    前往 Metrics Explorer

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果

  2. 在查詢建構工具窗格的工具列中,選取名稱為  MQL PromQL 的按鈕。
  3. 確認已在「Language」(語言) 切換按鈕中選取「PromQL」。語言切換按鈕位於同一工具列,可供你設定查詢格式。
  4. 在編輯器中輸入下列查詢,然後按一下「執行查詢」
    {"workload.googleapis.com/saphana.connection.count", monitored_resource="gce_instance"}
    

查看資訊主頁

如要查看 HANA 指標,您必須設定圖表或資訊主頁。HANA 整合包含一或多個資訊主頁。 設定整合功能後,Ops Agent 就會開始收集指標資料,並自動安裝所有資訊主頁。

您也可以查看資訊主頁的靜態預覽畫面,不必安裝整合服務。

如要查看已安裝的資訊主頁,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,前往「Dashboards」(資訊主頁) 頁面:

    前往「Dashboards」(資訊主頁)

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果

  2. 選取「資訊主頁清單」分頁,然後選擇「整合」類別。
  3. 按一下要查看的資訊主頁名稱。

如果您已設定整合功能,但尚未安裝資訊主頁,請檢查作業套件代理程式是否正在執行。如果資訊主頁中的圖表沒有指標資料,資訊主頁安裝作業就會失敗。作業套件代理程式開始收集指標後,系統就會為您安裝資訊主頁。

如要查看資訊主頁的靜態預覽畫面,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 「Integrations」(整合) 頁面

    前往「整合」

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果

  2. 按一下「Compute Engine」部署平台篩選器。
  3. 找出 HANA 的項目,然後按一下「查看詳細資料」
  4. 選取「資訊主頁」分頁標籤,即可查看靜態預覽畫面。如果已安裝資訊主頁,請點選「查看資訊主頁」前往。

如要進一步瞭解 Cloud Monitoring 中的資訊主頁,請參閱「資訊主頁和圖表」。

如要進一步瞭解如何使用「整合」頁面,請參閱「管理整合」一文。

安裝快訊政策

快訊政策會指示 Cloud Monitoring 在發生指定情況時通知您。 HANA 整合功能包含一或多項快訊政策,供您使用。您可以在 Monitoring 的「Integrations」(整合) 頁面中查看及安裝這些快訊政策。

如要查看可用快訊政策的說明並安裝,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 「Integrations」(整合) 頁面

    前往「整合」

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果

  2. 找出 HANA 的項目,然後按一下「查看詳細資料」
  3. 選取「快訊」分頁標籤。這個分頁會說明可用的快訊政策,並提供安裝介面。
  4. 安裝快訊政策。快訊政策需要知道在觸發快訊時,要將通知傳送至何處,因此需要您提供安裝資訊。如要安裝快訊政策,請按照下列步驟操作:
    1. 從可用的警報政策清單中,選取要安裝的政策。
    2. 在「設定通知」部分,選取一或多個通知管道。您可以選擇停用通知管道,但這麼做的話,快訊政策會以無聲方式觸發。您可以在「監控」中查看狀態,但不會收到任何通知。

      如要進一步瞭解通知管道,請參閱「管理通知管道」。

    3. 按一下「建立政策」

如要進一步瞭解 Cloud Monitoring 中的快訊政策,請參閱快訊簡介

如要進一步瞭解如何使用「整合」頁面,請參閱「管理整合」一文。

後續步驟

如要逐步瞭解如何使用 Ansible 安裝作業套件代理程式、設定第三方應用程式,以及安裝範例資訊主頁,請觀看「 安裝 Ops Agent 以排解第三方應用程式的問題」影片。