【问题标题】:what is the meaning of 'window' in results from k8s metric server apik8s metric server api结果中的“窗口”是什么意思
【发布时间】:2021-09-02 21:57:05
【问题描述】:

当我在 cli 上键入此命令时:

kubectl get --raw /apis/metrics.k8s.io/v1beta1/namespaces/<NAMESPACE>/pods/<POD_NAME> | jq

我可以得到如下结果:

{
  "kind": "PodMetrics",
  "apiVersion": "metrics.k8s.io/v1beta1",
  "metadata": {
    "name": "busybox",
    "namespace": "default",
    "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/busybox",
    "creationTimestamp": "2019-12-10T18:23:20Z"
  },
  "timestamp": "2019-12-10T18:23:12Z",
  "window": "30s",
  "containers": [
    {
      "name": "busybox",
      "usage": {
        "cpu": "0",
        "memory": "364Ki"
      }
    }
  ]
}

那个“窗口”项是什么意思? 我真的很想知道它到底是什么。

【问题讨论】:

  • CPU 报告为一段时间内 CPU 内核的平均使用率。该值是通过对内核提供的累积 CPU 计数器(在 Linux 和 Windows 内核中)取一个速率得出的。 kubelet 选择费率计算的窗口。从here 获得,但不确定它是否代表同一事物。

标签: kubernetes-metrics


【解决方案1】:

根据k8ssource code

// PodMetrics sets resource usage metrics of a pod.
type PodMetrics struct {
    metav1.TypeMeta
    metav1.ObjectMeta

    // The following fields define time interval from which metrics were
    // collected from the interval [Timestamp-Window, Timestamp].
    Timestamp metav1.Time
    Window    metav1.Duration

    // Metrics for all containers are collected within the same time window.
    Containers []ContainerMetrics
}

您很可能对此评论感兴趣:

以下字段定义了从区间 [Timestamp-Window, Timestamp] 收集指标的时间区间。

因此,使用结果是在此窗口/时间间隔内收集的平均数据。

【讨论】:

  • 非常感谢您的帮助。非常感谢!!
  • 你好@irrain,如果你觉得它有帮助,请考虑接受或投票。 stackoverflow.com/help/privileges/comment
猜你喜欢
  • 2016-12-14
  • 2012-11-02
  • 1970-01-01
  • 1970-01-01
  • 2022-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多