[英]Kubernetes Prometheus metric for HPA (horizontal pod autoscaler) `currentCPUUtilizationPercentage`?
On a Kube.netes cluster with CoreOS Prometheus Operator scraping all standard cluster metrics, what Prometheus metric would show me the currentCPUUtilizationPercentage
value for a simple HPA (horizontal pod autoscaler)?在使用 CoreOS Prometheus Operator 抓取所有标准集群指标的 Kube.netes 集群上,什么 Prometheus 指标会显示简单 HPA(水平 pod 自动缩放器)的
currentCPUUtilizationPercentage
值?
If I setup a simple hpa like:如果我设置一个简单的 hpa,例如:
$ kubectl autoscale deployment php-apache --cpu-percent=30 --min=3 --max=10
And then if I do kubectl get hpa php-apache -o yaml
I see something like:然后如果我执行
kubectl get hpa php-apache -o yaml
我会看到类似这样的内容:
spec:
maxReplicas: 10
minReplicas: 3
targetCPUUtilizationPercentage: 30
...
status:
currentCPUUtilizationPercentage: 28
currentReplicas: 9
desiredReplicas: 9
...
I want to see that currentCPUUtilizationPercentage
in Prometheus.我想在 Prometheus 中查看
currentCPUUtilizationPercentage
。 I've done a bunch of Prometheus queries to look for this.我做了一堆普罗米修斯查询来寻找这个。
I've searched all metrics tagged {hpa="php-apache"}
and I see many hpa metrics, but not the metric I'm looking or.我搜索了所有标记
{hpa="php-apache"}
的指标,我看到了许多 hpa 指标,但没有看到我正在寻找的指标。 I can see kube_hpa_spec_target_metric
set to 30 and I can see current status metrics like kube_hpa_status_condition
but not the current cpu metric value that I want to see.我可以看到
kube_hpa_spec_target_metric
设置为 30,我可以看到当前状态指标,如kube_hpa_status_condition
,但看不到我想看到的当前 cpu 指标值。
I've searched all metrics tagged {metric_name="cpu"}
and only see kube_hpa_spec_target_metric
我搜索了所有标记
{metric_name="cpu"}
的指标,但只看到kube_hpa_spec_target_metric
I've searched all container and pod related metrics tagged {container="my-container-name"}
and {pod=~"my-pod-prefix.*"}
and I see several cpu related metrics like container_cpu_usage_seconds_total
abnd container_spec_cpu_quota
but nothing similar to or nothing that seems to be able to be used in calculating the currentCPUUtilizationPercentage
value that I'm looking for?我搜索了所有标记
{container="my-container-name"}
和{pod=~"my-pod-prefix.*"}
容器和 pod 相关指标,我看到了几个与 cpu 相关的指标,例如container_cpu_usage_seconds_total
abnd container_spec_cpu_quota
但什么也没有类似于或似乎无法用于计算我正在寻找的currentCPUUtilizationPercentage
值?
FYI, this is on Kube.netes 1.17.x and using a recent version of CoreOS Prometheus Operator.仅供参考,这是在 Kube.netes 1.17.x 上使用的最新版本的 CoreOS Prometheus Operator。
If I remember correctly currentCPUUtilizationPercentage is a k8 internal metrics for HPA and not exposed directly as a metrics you can scrape with Prometheus.如果我没记错的话,currentCPUUtilizationPercentage 是 HPA 的 k8 内部指标,不会直接公开为可以使用 Prometheus抓取的指标。 see https://github.com/kube.netes/community/blob/master/contributors/design-proposals/autoscaling/horizontal-pod-autoscaler.md#autoscaling-algorithm
参见https://github.com/kube.netes/community/blob/master/contributors/design-proposals/autoscaling/horizontal-pod-autoscaler.md#autoscaling-algorithm
you probably could scrape component of currentCPUUtilizationPercentage metrics and create custom metrics to see it in Prometheus.您可能可以抓取currentCPUUtilizationPercentage 指标的组件并创建自定义指标以在 Prometheus 中查看它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.