在 Azure IoT Edge 中访问内置指标

适用范围:IoT Edge 1.5 checkmark IoT Edge 1.5

重要

IoT Edge 1.5 LTS 是受支持的版本。 IoT Edge 1.4 LTS 于 2024 年 11 月 12 日终止。 如果使用的是早期版本,请参阅 Update IoT Edge

IoT Edge运行时组件(IoT Edge中心和IoT Edge代理)以 Prometheus exposition 格式生成内置指标。 访问这些指标以远程监控和掌握物联网边缘设备的运行状况。

默认情况下, edgeHubedgeAgent 模块公开 端口 9600http://edgeHub:9600/metricshttp://edgeAgent:9600/metrics) 上的指标。 默认情况下,指标不会映射到主机。

若要从主机访问指标,请公开和映射模块 createOptions中的指标端口。 以下示例将默认指标端口映射到主机上的端口 9601:

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

映射 edgeHub 和 edgeAgent 指标终结点时,请选择不同的唯一主机端口号。

注意事项

您必须将环境变量 httpSettings__enabled 设置为 true,以便收集内置指标。

有关可禁用指标的环境变量的详细信息,请参阅 azure/iotedge 存储库文档

可用度量值

指标包括标识所收集指标的性质的标记。 所有指标包括以下标记:

标记 描述
iothub 设备与之通信的中心
边缘设备 当前设备的 ID
实例编号 表示当前运行时的 GUID。 重启后,所有指标都会重置。 此 GUID 有助于协调重启。

Prometheus 博览会格式包括四种核心指标类型:计数器、仪表、直方图和摘要。 有关不同指标类型的详细信息,请参阅 Prometheus 指标类型文档

内置直方图和摘要指标的分量为 0.1、0.5、0.9 和 0.99。

edgeHub 模块生成以下指标:

名称 维度 描述
edgehub_gettwin_total source(操作源)
id(模块 ID)
类型:计数器
GetTwin 调用的总数。
edgehub_messages_received_total route_output(发送消息的输出)
id
类型:计数器
从客户端接收的消息总数。
edgehub_messages_sent_total from(消息源)
to(消息目标)
from_route_output
to_route_input(消息目标输入)
priority(到目标的消息优先级)
类型:计数器
发送到客户端或上游的消息总数
to_route_input 为空当 to 是 $upstream 时。
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(无路由、TTL过期)
from
from_route_output
类型:计数器
因某种原因而删除的消息总数
edgehub_messages_unack_total reason (存储故障)
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 的总次数
edgehub_client_connect_success_total id 类型:计数器
客户端成功连接到 edgeHub 的总次数
edgehub_client_disconnect_total id 类型:计数器
客户端与 edgeHub 断开连接的总次数
edgehub_connected_clients 类型:仪表
连接到 edgeHub 的客户端的当前数量

edgeAgent 模块生成以下指标:

名称 维度 描述
edgeAgent_total_time_running_correctly_seconds module_name 类型:仪表
指定模块在部署中进入运行状态的时间量
edgeAgent_total_time_expected_running_seconds module_name 类型:仪表
在部署中指定模块的时间
edgeAgent_module_start_total module_namemodule_version 类型:计数器
edgeAgent 请求 Docker 启动模块的次数
edgeAgent_module_stop_total module_namemodule_version 类型:计数器
edgeAgent 请求 Docker 停止模块的次数
edgeAgent_module_prepare_update_total module_namemodule_version 类型:计数器
edgeAgent 准备模块更新的次数
edgeAgent_command_latency_seconds command 类型:仪表
Docker 执行给定命令所用的时间。 可能的命令有:创建、更新、移除、启动、停止和重启
edgeAgent_iothub_syncs_total 类型:计数器
edgeAgent 尝试将其孪生与 iotHub 同步的成功和失败次数。 此数目包括请求孪生的代理和通知孪生更新的中心
edgeAgent_unsuccessful_iothub_syncs_total 类型:计数器
Edge Agent 与 IoT Hub 同步其数字孪生失败的次数。
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 类型:仪表
可用的内存
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安全守护程序版本。

后续步骤