Kubernetes prometheus metrics for running pods and nodes?

六月ゝ 毕业季﹏ 提交于 2019-12-22 08:39:07

问题


I've set up prometheus to monitor kubernetes metrics by following the prometheus documentation.

A lot of useful metrics now show up in prometheus.

However, I can't see any metrics referencing the status of my pods or nodes.

Ideally - I'd like to be able to graph the pod status (Running, Pending, CrashLoopBackOff, Error) and nodes (NodeReady, Ready).

Is this metric anywhere? If not, can I add it somewhere? And how?


回答1:


The regular kubernetes setup does not expose these metrics - further discussion here.

However, another service can be used to collect these cluster level metrics: https://github.com/kubernetes/kube-state-metrics.

This currently provides node_status_ready and pod_container_restarts which sound like what I want.




回答2:


I don't think such metrics exist.

You have to modify the source code to add them. Take a look at this file on how to register a metric: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/metrics/metrics.go, and take a look at this line on how to record a metric: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/pleg/generic.go#L180




回答3:


I've found that I can monitor these metrics using heapster & snap, which is a plausible workaround for my case. Let me know if that's something you're also using and I'll give you the proper metrics to get this data.



来源:https://stackoverflow.com/questions/39349744/kubernetes-prometheus-metrics-for-running-pods-and-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!