简体   繁体   English

从kubernetes集群获取容器资源指标

[英]Getting container resource metrics from kubernetes cluster

I am exploring client-go library for collecting resource metric for a kubernetes cluster. 我正在探索client-go库来收集kubernetes集群的资源指标。 I am more keen on collecting the container metrics from all the pods. 我更热衷于从所有pod中收集容器指标。

But according to the wiki, https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/ , i see that we can only get pod or node level metrics and not container level metrics. 但是根据wiki, https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/ ,我发现我们只能获得pod或节点级指标而不是容器级指标。

Is there a way i can collect container level metric (like the way docker api gives the metrics for a container)? 有没有办法可以收集容器级别指标(比如docker api为容器提供指标的方式)?

You should deploy the External Metric server like Prometheus Adapter (example of full metric solution mentioned in official doc you linked). 您应该部署外部度量服务器,如Prometheus适配器(您链接的官方文档中提到的完整度量标准解决方案的示例)。

The quickest way to achieve it is via kube-prometheus repository, which is part of prometheus-operator project. 实现它的最快方法是通过kube-prometheus存储库,它是prometheus-operator项目的一部分。 It already includes kube-state-metrics, which generates custom metrics of your interest ( Pod Metrics ), example of container related one: kube_pod_container_resource_requests_cpu_cores. 它已经包含kube-state-metrics,它生成您感兴趣的自定义指标( Pod度量标准 ),与容器相关的示例:kube_pod_container_resource_requests_cpu_cores。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM