【问题标题】:How to get in prometheus the pods that have been running in the last 3 months如何在 prometheus 中获取最近 3 个月内运行的 pod
【发布时间】:2021-11-11 06:15:41
【问题描述】:

您好,我需要知道如何在 prometheus 中查询最近 3 个月在 k8s 集群中运行的 pod。我尝试过使用kube_pod_start_time * 1000,但我只获得了 pod 启动的时间

谢谢!!

【问题讨论】:

  • 请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: kubernetes prometheus monitoring kubernetes-pod


【解决方案1】:

此查询表达式将返回运行时间超过 90 天的 pod 名称及其相应年龄。

floor(sum by (pod) (time() - kube_pod_created) / 86400 > 90)

这将返回过去 90 天内运行的 pod 的名称。 请注意,也可以存在已退出的 pod,但现在不存在。

sum by (pod) (min_over_time(kube_pod_start_time[90d]))

【讨论】:

    猜你喜欢
    • 2019-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    • 2014-03-21
    • 1970-01-01
    • 2022-12-15
    相关资源
    最近更新 更多