Prometheus Metrics接口

功能说明

提供Metrics接口,供Prometheus调用和集成。

URL

GET http://ip:port/metrics

NPU Exporter为了安全考虑,默认启用容器级别端口(默认8082),请求IP为Kubernetes容器IP,当K8s网络插件为calico时,网络策略设置为允许label为app=prometheus的应用访问。

请求参数

响应说明

按照Prometheus的专用格式返回数据,相关数据信息如下所示,仅供参考,以实际回显为准。数据信息的详细说明参见下文或数据信息说明.xlsx。Prometheus自带数据信息无需关注,不在此展示说明。有部分数据信息仅支持某种产品形态,具体以实际上报的数据信息为准。

...

# HELP machine_npu_nums Amount of npu installed on the machine.
# TYPE machine_npu_nums gauge
machine_npu_nums 8
# HELP npu_chip_info_aicore_current_freq the npu ai core current frequency, unit is 'MHz'
# TYPE npu_chip_info_aicore_current_freq gauge
npu_chip_info_aicore_current_freq{container_name="",id="0",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:61:00.0",pod_name="",vdie_id="185011D4-21104518-A0C4ED94-14CC040A-56102003"} 1000 1723621883587
npu_chip_info_aicore_current_freq{container_name="",id="1",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:DB:00.0",pod_name="",vdie_id="185011D4-21E04718-93B2ED94-14CC040A-BF102003"} 1000 1723621883932
npu_chip_info_aicore_current_freq{container_name="",id="2",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:B2:00.0",pod_name="",vdie_id="185011D4-20C02418-59D4ED94-14CC040A-F9102003"} 1000 1723621884277
npu_chip_info_aicore_current_freq{container_name="",id="3",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:3E:00.0",pod_name="",vdie_id="185011D4-21502C18-0464ED94-14CC040A-6E102003"} 1000 1723621884682
npu_chip_info_aicore_current_freq{container_name="",id="4",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:60:00.0",pod_name="",vdie_id="185011D4-21A02418-64946D94-14CC040A-F8102003"} 1000 1723621885026
npu_chip_info_aicore_current_freq{container_name="",id="5",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:DA:00.0",pod_name="",vdie_id="185011DC-21F02B18-C4B66D94-14CC040A-57102003"} 1000 1723621885385
npu_chip_info_aicore_current_freq{container_name="",id="6",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:B1:00.0",pod_name="",vdie_id="185011D4-20602118-14646D94-14CC040A-8A102003"} 1000 1723621885784
npu_chip_info_aicore_current_freq{container_name="",id="7",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:3D:00.0",pod_name="",vdie_id="185011D4-21504C18-10656D94-14CC040A-6B102003"} 1000 1723621886131
# HELP npu_chip_info_bandwidth_rx the npu interface receive speed, unit is 'MB/s'
# TYPE npu_chip_info_bandwidth_rx gauge
npu_chip_info_bandwidth_rx{container_name="",id="0",model_name="910A-Ascend-V1",namespace="",pcie_bus_info="0000:61:00.0",pod_name="",vdie_id="185011D4-21104518-A0C4ED94-14CC040A-56102003"} 0 1723621883587
...

本接口提供查询的Prometheus labels包含几个部分。

  • 如果进程运行在主机上,Pod没有使用NPU,则pod_name、container_name和namespace的值将为空。
  • NPU Exporter是通过调用底层的HDK接口,获取相应的信息。数据信息调用的HDK接口请参考调用的HDK接口
  • 若查询某项数据信息时,NPU Exporter组件不支持该设备形态或调用HDK接口失败,则不会上报该数据信息。

调用的HDK接口

NPU Exporter是通过调用底层的HDK接口,获取相应的信息。数据信息调用的HDK接口请参考NPU Exporter调用的HDK接口.xlsx。查找数据信息对应的HDK接口,可参考如下步骤。

  1. 登录昇腾计算文档中心,选择单击对应产品名称,进入文档界面。例如Atlas 800I A2 推理服务器产品的用户,单击“Atlas 800I A2”。
  2. 在左侧导航栏找到“二次开发”,根据接口的类型选择对应文档。

    • DCMI接口选择“API参考”,单击进入文档页面。
    • HCCN Tool接口选择“接口参考”,单击进入文档页面。

  3. 在文档首页搜索栏中,直接搜索对应的接口名称或者关键词,获取接口的相关信息。

状态码

表12 状态码

状态码

含义

200

正常状态。

307

临时跳转。

500

服务器内部错误。