如何在 prometheus 中获取最近 3 个月 运行 的 pods

How to get in prometheus the pods that have been running in the last 3 months

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

谢谢!!

这个查询表达式会return pods 的名字和他们对应的年龄,即运行宁超过90天。

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

这一个将 return 过去 90 天内 运行 的 pods 的名字。 注意也可以退出pods,现在不存在了。

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