You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MetricServiceClient获取GKE指标时的API调用路径疑问

问题解答

这段代码直接调用的是monitoring.googleapis.com服务,kubernetes.io/node/cpu/allocatable_utilization并不是一个可调用的服务地址,而是Google Cloud Monitoring中存储的GKE节点CPU可分配利用率指标的类型标识符。

具体逻辑如下:

  • 你通过monitoring_v3.MetricServiceClient创建的客户端,本质是向Google Cloud Monitoring的RPC服务(monitoring.googleapis.com)发起请求。
  • 请求里的filter参数指定metric.type = "kubernetes.io/node/cpu/allocatable_utilization",是告诉Monitoring服务:需要获取这个特定类型的指标时间序列数据。
  • Monitoring服务内部已采集并存储了GKE的各类指标(包括该CPU利用率指标),它会根据你指定的过滤条件、时间区间等参数,返回对应的指标数据给客户端。

简单来说,是你的代码调用monitoring.googleapis.com,再由这个服务根据你指定的指标类型标识符返回对应数据,不存在monitoring.googleapis.com调用kubernetes.io/node/cpu/allocatable_utilization的说法。

内容的提问来源于stack exchange,提问作者Dev Jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 15:24:52