大网数据广告活动
服务器运维问答

How to extract Kubernetes core metrics usage over time - metrics-server

· 52CE 我爱测

I am using metrics-server in Kubernetes. How do I extract data relating to these core metrics: Number of pods running for each horizontal pod over a period of time CPU usage at certain points in time Number of failures / restarts…

问题原文

原帖链接 · cfbd · CC BY-SA 4.0

I am using metrics-server in Kubernetes. How do I extract data relating to these core metrics:

  • Number of pods running for each horizontal pod over a period of time
  • CPU usage at certain points in time
  • Number of failures / restarts over a period of time

已采纳解答

原帖链接 · yyyyahir · CC BY-SA 4.0

Metrics-server has a built-in API endpoint where current usage of resources is reflected, and can be accessed with a client library or proxying the master endpoints, for instance via kubectl proxy to expose the metrics in localhost or k get --raw "/apis/metrics.k8s.io/v1beta1/pods" |jq . to get a JSON result (with jq previously installed).

Keep in mind that metric aggregation is not supported yet in this API. Usually, these are collected by a third-party agent and aggregated in a separate backend, for example, Stackdriver monitoring or Datadog.

Now, for the specific information you want to fetch from your cluster, there is no metric specific for the number of replicas created by the HPA. The system uses the resource usage metric in order to determine when to spawn more replicas of a deployment.

The CPU usage case seems very specific for already aggregated metrics, so you can use an aggregation solution for Kubernetes, like the ones mentioned before.

Finally, there is also not specific metric for failures and this specific information doesn't seem to be part of any metrics pipeline but rather logging, as failures usually get logged but can be aggregated afterwards to create metrics.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。