自定义指标扩缩容(2)

2023-09-01 09:59:53 浏览数 (2)

podinfo应用暴露了一个名为http_requests_total的自定义metric。Prometheas适配器删除_total后缀,并将度量标记为计数器度量(counter metric)。 从自定义metrics API中获取每秒请求总数:

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/http_requests" | jq .

查询结果:

{

"kind": "MetricValueList",

"apiVersion": "custom.metrics.k8s.io/v1beta1",

"metadata": {

"selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/http_requests"

},

"items": [

{

"describedObject": {

"kind": "Pod",

"namespace": "default",

"name": "podinfo-6b86c8ccc9-kv5g9",

"apiVersion": "/__internal"

},

"metricName": "http_requests",

"timestamp": "2018-01-10T16:49:07Z",

"value": "901m"

},

{

"describedObject": {

"kind": "Pod",

"namespace": "default",

"name": "podinfo-6b86c8ccc9-nm7bl",

"apiVersion": "/__internal"

},

"metricName": "http_requests",

"timestamp": "2018-01-10T16:49:07Z",

"value": "898m"

}

]

}

0 人点赞