存取 Azure IoT Edge 中的內建計量

適用於: IoT Edge 1.5 核取記號 IoT Edge 1.5 IoT Edge 1.4 核取記號 IoT Edge 1.4

重要

IoT Edge 1.5 LTS 和 IoT Edge 1.4 LTS 為支援的版本。 IoT Edge 1.4 LTS 於 2024 年 11 月 12 日結束生命週期。 如果您是舊版,請參閱更新 IoT Edge

IoT Edge 執行階段元件、IoT Edge 中樞和 IoT Edge 代理程式會以 Prometheus 展示格式產生內建計量。 從遠端存取這些計量,即可監視及了解 IoT Edge 裝置的健康情況。

您可以使用自己的解決方案來存取這些計量。 或者,您可以使用計量收集器模組來處理收集內建計量,並將其傳送至 Azure 監視器或 Azure IoT 中樞。 如需詳細資訊,請參閱收集及傳輸計量

edgeHubedgeAgent 模組連接埠 9600 上 (http://edgeHub:9600/metricshttp://edgeAgent:9600/metrics),預設會自動公開計量。 預設為不會對應至主機的連接埠。

藉由從模組 createOptions 的公開和對應計量埠,從主機存取計量。 下列範例會將預設計量埠對應至主機上的連接埠 9601:

{
  "ExposedPorts": {
    "9600/tcp": {}
  },
  "HostConfig": {
    "PortBindings": {
      "9600/tcp": [
        {
          "HostPort": "9601"
        }
      ]
    }
  }
}

如果您要對應 edgeHub 和 edgeAgent 的計量端點,請選擇不同的和唯一的主機埠號碼。

注意

環境變數 httpSettings__enabled 不能設定為 false,內建計量才能用於集合。

可用來停用計量的環境變數,列於 azure/iotedge 存放庫文件中

可用的計量

計量包含標記,可協助識別所收集計量的本質。 所有計量都包含下列標記:

標記 描述
iothub 裝置正在交談的中樞
edge_device 目前裝置的識別碼
instance_number 表示目前執行階段的 GUID。 重新啟動時,所有計量都會重設。 此 GUID 可讓您更輕鬆地協調重新開機。

在 Prometheus 展示格式中,有四種核心計量類型:計數器、量測計、長條圖和摘要。 如需不同計量類型的詳細資訊,請參閱 Prometheus 計量類型文件

針對內建長條圖和摘要計量提供的分位數為 0.1、0.5、0.9 和 0.99。

edgeHub 模組會產生下列計量:

名稱 維度 描述
edgehub_gettwin_total source (作業來源)
id (模組識別碼)
類型:計數器
GetTwin 呼叫次數總計
edgehub_messages_received_total route_output (傳送訊息的輸出)
id
類型:計數器
由用戶端接收的訊息數目
edgehub_messages_sent_total from (訊息來源)
to (訊息目的地)
from_route_output
to_route_input (訊息目的地輸入)
priority (對目的地之訊息優先順序)
類型:計數器
傳送至用戶端或上游的訊息總數
to 為 $upstream 時,to_route_input 為空
edgehub_reported_properties_total target (更新目標)
id
類型:計數器
報告屬性更新呼叫總數
edgehub_message_size_bytes id
類型:摘要
來自用戶端的訊息大小
若特定期間內 (現為 10 分鐘) 未報告新的量測,值會報告為 NaN。若為 summary 類型,會發出對應的 _count_sum 計數器。
edgehub_gettwin_duration_seconds source
id
類型:摘要
取得對應項作業所花費的時間
edgehub_message_send_duration_seconds from
to
from_route_output
to_route_input
類型:摘要
傳送訊息所花費的時間
edgehub_message_process_duration_seconds from
to
priority
類型:摘要
從佇列處理訊息所花費的時間
edgehub_reported_properties_update_duration_seconds target
id
類型:摘要
更新報告屬性所花費的時間
edgehub_direct_method_duration_seconds from (呼叫者)
to (接收者)
類型:摘要
解決直接訊息所花費的時間
edgehub_direct_methods_total from
to
類型:計數器
直接傳送的訊息總數
edgehub_queue_length endpoint (訊息來源)
priority (佇列優先順序)
類型:量測計
指定優先順序的 edgeHub 佇列目前長度
edgehub_messages_dropped_total reason (no_route、ttl_expiry)
from
from_route_output
類型:計數器
因為原因而移除的訊息總數
edgehub_messages_unack_total reason (storage_failure)
from
from_route_output
類型:計數器
因為儲存體失敗而未確認的訊息總數
edgehub_offline_count_total id 類型:計數器
edgeHub 離線的總次數
edgehub_offline_duration_seconds id 類型:摘要
時間邊緣中樞已離線
edgehub_operation_retry_total id
operation (作業時間)
類型:計數器
重試 edgeHub 作業的總次數
edgehub_client_connect_failed_total id
reason (未驗證)
類型:計數器
用戶端無法連線到 edgeHub 的總次數

edgeAgent 模組會產生下列計量:

名稱 維度 描述
edgeAgent_total_time_running_correctly_seconds module_name 類型:量測計
模組在部署中指定的時間量,且處於執行中狀態
edgeAgent_total_time_expected_running_seconds module_name 類型:量測計
部署中指定模組的時間量
edgeAgent_module_start_total module_name, module_version 類型:計數器
edgeAgent 要求 Docker 啟動模組的次數
edgeAgent_module_stop_total module_name, module_version 類型:計數器
edgeAgent 要求 Docker 停止模組的次數
edgeAgent_command_latency_seconds command 類型:量測計
Docker 執行指定命令所花費的時間長度。 可能的命令包括:建立、更新、移除、啟動、停止和重新啟動
edgeAgent_iothub_syncs_total 類型:計數器
edgeAgent 嘗試將其對應項與 iotHub 同步的次數,含成功和失敗。 此號碼同時包含代理程式要求對應項和中樞通知對應項更新
edgeAgent_unsuccessful_iothub_syncs_total 類型:計數器
edgeAgent 無法將其對應項與 iotHub 同步的次數。
edgeAgent_deployment_time_seconds 類型:計數器
收到變更之後,完成新部署所花費的時間量。
edgeagent_direct_method_invocations_count method_name 類型:計數器
呼叫內建 edgeAgent 直接方法的次數,例如 Ping 或 Restart。
edgeAgent_host_uptime_seconds 類型:量測計
主機已開啟的時間長度
edgeAgent_iotedged_uptime_seconds 類型:量測計
已執行 iotedged 的累計時間
edgeAgent_available_disk_space_bytes disk_namedisk_filesystemdisk_filetype 類型:量測計
磁碟上剩餘的空間量
edgeAgent_total_disk_space_bytes disk_namedisk_filesystemdisk_filetype 類型:量測計
磁碟的大小
edgeAgent_used_memory_bytes module_name 類型:量測計
所有流程使用的 RAM 數量
edgeAgent_total_memory_bytes module_name 類型:量測計
可用的 RAM
edgeAgent_used_cpu_percent module_name 類型:長條圖
所有流程使用的 CPU 百分比
edgeAgent_created_pids_total module_name 類型:量測計
容器已建立的流程或執行緒數目
edgeAgent_total_network_in_bytes module_name 類型:量測計
從網路接收的位元組數目
edgeAgent_total_network_out_bytes module_name 類型:量測計
傳送給網路的位元組數目
edgeAgent_total_disk_read_bytes module_name 類型:量測計
從磁碟讀取的位元組數目
edgeAgent_total_disk_write_bytes module_name 類型:量測計
寫入至磁碟的位元組數目
edgeAgent_metadata edge_agent_versionexperimental_featureshost_information 類型:量測計
關於裝置的一般中繼資料。 值一律為 0,資訊會編碼在標記中。 請注意 experimental_featureshost_information 是 json 物件。 host_information 看起來會像 {"OperatingSystemType": "linux", "Architecture": "x86_64", "Version": "1.2.7", "Provisioning": {"Type": "dps.tpm", "DynamicReprovisioning": false, "AlwaysReprovisionOnStartup": false}, "ServerVersion": "20.10.11+azure-3", "KernelVersion": "5.11.0-1027-azure", "OperatingSystem": "Ubuntu 20.04.4 LTS", "NumCpus": 2, "Virtualized": "yes"}。 注意 ServerVersion 是 Docker 版本,而且 Version 是IoT Edge 安全性精靈版本。

下一步