开发者社区> 问答> 正文

使用curl检索自定义`custom.metrics.k8s.io`值

k8s小能手 2019-02-22 15:57:37 421

我可以列出所有custom.metrics可用的,但我不知道如何查询单个值。例如,我尝试过:

curl http://localhost:8001/apis/custom.metrics.k8s.io/v1beta1/ | jq .

{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "custom.metrics.k8s.io/v1beta1",
"resources": [

{
  "name": "deployments.apps/aws_sqs_approximate_number_of_messages_visible_average",
  "singularName": "",
  "namespaced": false,
  "kind": "MetricValueList",
  "verbs": [
    "get"
  ]
}

]
}
但如果我试试这个:

curl http://localhost:8001/apis/custom.metrics.k8s.io/v1beta1/deployments.apps/aws_sqs_approximate_number_of_messages_visible_average | jq .

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {

},
"status": "Failure",
"message": "the server could not find the requested resource",
"reason": "NotFound",
"details": {

},
"code": 404
}

分享到
取消 提交回答
全部回答(1)
  • k8s小能手
    2019-07-17 23:29:11

    就像资源指标一样,自定义指标也绑定到Kubernetes对象。您在URL中缺少的是您希望度量标准与之相关的资源。例如,自定义指标与Pod相关,但部署也是如此。

    尝试根据您的需求调整此网址:

    kubectl get --raw \
    '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pod/podinfo-67c9fd95d-fqk4g/http_requests_per_second' \
    | jq .

    0 0
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

推荐文章