[英]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.