[英]Kubernetes Prometheus metric for HPA (horizontal pod autoscaler) `currentCPUUtilizationPercentage`?
在使用 CoreOS Prometheus Operator 抓取所有标准集群指标的 Kube.netes 集群上,什么 Prometheus 指标会显示简单 HPA(水平 pod 自动缩放器)的currentCPUUtilizationPercentage
值?
如果我设置一个简单的 hpa,例如:
$ kubectl autoscale deployment php-apache --cpu-percent=30 --min=3 --max=10
然后如果我执行kubectl get hpa php-apache -o yaml
我会看到类似这样的内容:
spec:
maxReplicas: 10
minReplicas: 3
targetCPUUtilizationPercentage: 30
...
status:
currentCPUUtilizationPercentage: 28
currentReplicas: 9
desiredReplicas: 9
...
我想在 Prometheus 中查看currentCPUUtilizationPercentage
。 我做了一堆普罗米修斯查询来寻找这个。
我搜索了所有标记{hpa="php-apache"}
的指标,我看到了许多 hpa 指标,但没有看到我正在寻找的指标。 我可以看到kube_hpa_spec_target_metric
设置为 30,我可以看到当前状态指标,如kube_hpa_status_condition
,但看不到我想看到的当前 cpu 指标值。
我搜索了所有标记{metric_name="cpu"}
的指标,但只看到kube_hpa_spec_target_metric
我搜索了所有标记{container="my-container-name"}
和{pod=~"my-pod-prefix.*"}
容器和 pod 相关指标,我看到了几个与 cpu 相关的指标,例如container_cpu_usage_seconds_total
abnd container_spec_cpu_quota
但什么也没有类似于或似乎无法用于计算我正在寻找的currentCPUUtilizationPercentage
值?
仅供参考,这是在 Kube.netes 1.17.x 上使用的最新版本的 CoreOS Prometheus Operator。
如果我没记错的话,currentCPUUtilizationPercentage 是 HPA 的 k8 内部指标,不会直接公开为可以使用 Prometheus抓取的指标。 参见https://github.com/kube.netes/community/blob/master/contributors/design-proposals/autoscaling/horizontal-pod-autoscaler.md#autoscaling-algorithm
您可能可以抓取currentCPUUtilizationPercentage 指标的组件并创建自定义指标以在 Prometheus 中查看它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.