kubernetes 指标“/metrics/resource/v1alpha1”和“/metrics/cadvisor”端点之间的区别
Difference between kubernetes metrics "/metrics/resource/v1alpha1" and "/metrics/cadvisor" endpoints
我正在使用 Prometheus(prometheus-operator Helm chart)进行内存监控。
在调查值时,我注意到内存使用情况 (container_memory_working_set_bytes
) 正在从两个端点被抓取:
/metrics/cadvisor
/metrics/resource/v1alpha1
(/metrics/resource
来自 kubernetes 1.18)
我已经想出如何禁用图表中的一个端点,但我想了解两者的用途。
我明白 /metrics/cadvisor
return 的三个值 - pod 的容器(如果 pod 有多个容器则更多),一些特殊的容器 POD
(它是一些内部内存使用到 运行 POD服务?)和所有容器的总和(然后结果有空标签container=""
)。
另一方面,/metrics/resource/v1alpha1
return 仅 pod 容器的内存使用(没有 container="POD"
并且没有这些 container=""
的总和)
/metrics/resource/v1alpha1
是否计划取代 /metrics/cadvisor
作为单一指标来源?
看到两个端点(在 prometheus-operator
中默认启用)return 相同的指标任何 sum()
查询可以 return 值 2 与实际内存使用量一样大。
感谢对此主题的任何澄清!
答案不完整
I understand that /metrics/cadvisor returns three values - pod's
container (or more if a pod has multiple containers), some special
container POD (is it some internal memory usage to run a POD service?)
and a sum of all containers (then the result has empty label
container="").
container_name=="POD"
是 pods 的“暂停”容器。 pause container 是一个容器,其中包含 pod 的网络名称空间。 Kubernetes 创建暂停容器以获取相应 pod 的 IP 地址,并为加入该 pod 的所有其他容器设置网络命名空间。这个容器是整个生态系统的一部分,它首先在 pods 中启动,在调度另一个 pods 之前首先配置 PODs 网络。 pod 启动后 - 暂停容器无事可做。
暂停容器代码供您参考:https://github.com/kubernetes/kubernetes/tree/master/build/pause
暂停容器示例:
docker ps |grep pause
k8s_POD_etcd-master-1_kube-system_ea5105896423fc919bf9bfc0ab339888_0
k8s_POD_kube-scheduler-master-1_kube-system_155707e0c19147c8dc5e997f089c0ad1_0
k8s_POD_kube-apiserver-master-1_kube-system_fe660a7e8840003352195a8c40a01ef8_0
k8s_POD_kube-controller-manager-master-1_kube-system_807045fe48b23a157f7fe1ef20001ba0_0
k8s_POD_kube-proxy-76g9l_kube-system_e2348a94-eb96-4630-86b2-1912a9ce3a0f_0
k8s_POD_kube-flannel-ds-amd64-76749_kube-system_bf441436-bca3-4b49-b6fb-9e031ef7513d_0
container_name!=="POD"
它过滤掉暂停容器的指标流,一般不是元数据。大多数人,如果他们想绘制 Pod 中的容器图形,不希望看到暂停容器的资源使用情况,因为它做的不多。暂停容器的名称是一些容器运行时的实现细节,但并不适用于所有容器,也不保证会一直存在。
官方(过时的 v1.14)page 展示了 cadvisor 和 metrics 资源监控的区别:
Kubelet
The Kubelet acts as a bridge between the Kubernetes master and
the nodes. It manages the pods and containers running on a machine.
Kubelet translates each pod into its constituent containers and
fetches individual container usage statistics from the container
runtime, through the container runtime interface. For the legacy
docker integration, it fetches this information from cAdvisor. It then
exposes the aggregated pod resource usage statistics through the
kubelet resource metrics api. This api is served at
/metrics/resource/v1alpha1 on the kubelet’s authenticated and
read-only ports.
cAdvisor is an open source container resource usage and
performance analysis agent. It is purpose-built for containers and
supports Docker containers natively. In Kubernetes, cAdvisor is
integrated into the Kubelet binary. cAdvisor auto-discovers all
containers in the machine and collects CPU, memory, filesystem, and
network usage statistics. cAdvisor also provides the overall machine
usage by analyzing the ‘root’ container on the machine.
您还应该知道 kubelet 在 /metrics/cadvisor、/metrics/resource 和 /metrics/probes 端点公开指标。这 3 个指标没有相同的生命周期。
根据 helm prometheus values yaml - 有 3 个选项,您可以禁用不需要的选项
## Enable scraping /metrics/cadvisor from kubelet's service
##
cAdvisor: true
## Enable scraping /metrics/probes from kubelet's service
##
probes: true
## Enable scraping /metrics/resource from kubelet's service
##
resource: true
# From kubernetes 1.18, /metrics/resource/v1alpha1 renamed to /metrics/resource
resourcePath: "/metrics/resource/v1alpha1"
我的意见/metrics/resource/
不会取代google的顾问。只需在您的情况下禁用您不需要的东西。这仅取决于您的需求。例如,我找到了一篇文章 Kubernetes: monitoring with Prometheus – exporters, a Service Discovery, and its roles,其中使用 4 个 diff 工具来监控所有内容。
metrics-server – CPU、内存、file-descriptors、磁盘等集群
cAdvisor – Docker 守护进程指标 – 容器监控
kube-state-metrics – 部署,pods,节点
node-exporter:EC2 实例指标 – CPU、内存、网络
在你的情况下,为了监控内存,我相信这就足够了 1 :)
我正在使用 Prometheus(prometheus-operator Helm chart)进行内存监控。
在调查值时,我注意到内存使用情况 (container_memory_working_set_bytes
) 正在从两个端点被抓取:
/metrics/cadvisor
/metrics/resource/v1alpha1
(/metrics/resource
来自 kubernetes 1.18)
我已经想出如何禁用图表中的一个端点,但我想了解两者的用途。
我明白 /metrics/cadvisor
return 的三个值 - pod 的容器(如果 pod 有多个容器则更多),一些特殊的容器 POD
(它是一些内部内存使用到 运行 POD服务?)和所有容器的总和(然后结果有空标签container=""
)。
另一方面,/metrics/resource/v1alpha1
return 仅 pod 容器的内存使用(没有 container="POD"
并且没有这些 container=""
的总和)
/metrics/resource/v1alpha1
是否计划取代 /metrics/cadvisor
作为单一指标来源?
看到两个端点(在 prometheus-operator
中默认启用)return 相同的指标任何 sum()
查询可以 return 值 2 与实际内存使用量一样大。
感谢对此主题的任何澄清!
答案不完整
I understand that /metrics/cadvisor returns three values - pod's container (or more if a pod has multiple containers), some special container POD (is it some internal memory usage to run a POD service?) and a sum of all containers (then the result has empty label container="").
container_name=="POD"
是 pods 的“暂停”容器。 pause container 是一个容器,其中包含 pod 的网络名称空间。 Kubernetes 创建暂停容器以获取相应 pod 的 IP 地址,并为加入该 pod 的所有其他容器设置网络命名空间。这个容器是整个生态系统的一部分,它首先在 pods 中启动,在调度另一个 pods 之前首先配置 PODs 网络。 pod 启动后 - 暂停容器无事可做。
暂停容器代码供您参考:https://github.com/kubernetes/kubernetes/tree/master/build/pause
暂停容器示例:
docker ps |grep pause
k8s_POD_etcd-master-1_kube-system_ea5105896423fc919bf9bfc0ab339888_0
k8s_POD_kube-scheduler-master-1_kube-system_155707e0c19147c8dc5e997f089c0ad1_0
k8s_POD_kube-apiserver-master-1_kube-system_fe660a7e8840003352195a8c40a01ef8_0
k8s_POD_kube-controller-manager-master-1_kube-system_807045fe48b23a157f7fe1ef20001ba0_0
k8s_POD_kube-proxy-76g9l_kube-system_e2348a94-eb96-4630-86b2-1912a9ce3a0f_0
k8s_POD_kube-flannel-ds-amd64-76749_kube-system_bf441436-bca3-4b49-b6fb-9e031ef7513d_0
container_name!=="POD"
它过滤掉暂停容器的指标流,一般不是元数据。大多数人,如果他们想绘制 Pod 中的容器图形,不希望看到暂停容器的资源使用情况,因为它做的不多。暂停容器的名称是一些容器运行时的实现细节,但并不适用于所有容器,也不保证会一直存在。
官方(过时的 v1.14)page 展示了 cadvisor 和 metrics 资源监控的区别:
Kubelet
The Kubelet acts as a bridge between the Kubernetes master and the nodes. It manages the pods and containers running on a machine. Kubelet translates each pod into its constituent containers and fetches individual container usage statistics from the container runtime, through the container runtime interface. For the legacy docker integration, it fetches this information from cAdvisor. It then exposes the aggregated pod resource usage statistics through the kubelet resource metrics api. This api is served at /metrics/resource/v1alpha1 on the kubelet’s authenticated and read-only ports.
cAdvisor is an open source container resource usage and performance analysis agent. It is purpose-built for containers and supports Docker containers natively. In Kubernetes, cAdvisor is integrated into the Kubelet binary. cAdvisor auto-discovers all containers in the machine and collects CPU, memory, filesystem, and network usage statistics. cAdvisor also provides the overall machine usage by analyzing the ‘root’ container on the machine.
您还应该知道 kubelet 在 /metrics/cadvisor、/metrics/resource 和 /metrics/probes 端点公开指标。这 3 个指标没有相同的生命周期。
根据 helm prometheus values yaml - 有 3 个选项,您可以禁用不需要的选项
## Enable scraping /metrics/cadvisor from kubelet's service
##
cAdvisor: true
## Enable scraping /metrics/probes from kubelet's service
##
probes: true
## Enable scraping /metrics/resource from kubelet's service
##
resource: true
# From kubernetes 1.18, /metrics/resource/v1alpha1 renamed to /metrics/resource
resourcePath: "/metrics/resource/v1alpha1"
我的意见/metrics/resource/
不会取代google的顾问。只需在您的情况下禁用您不需要的东西。这仅取决于您的需求。例如,我找到了一篇文章 Kubernetes: monitoring with Prometheus – exporters, a Service Discovery, and its roles,其中使用 4 个 diff 工具来监控所有内容。
metrics-server – CPU、内存、file-descriptors、磁盘等集群
cAdvisor – Docker 守护进程指标 – 容器监控
kube-state-metrics – 部署,pods,节点
node-exporter:EC2 实例指标 – CPU、内存、网络
在你的情况下,为了监控内存,我相信这就足够了 1 :)