0

Hi I need to know how to query in prometheus the pods that have been running in the k8s cluster in the last 3 months. I have tried with kube_pod_start_time * 1000 but I only obtain the time the pod started

Thanks!!

ichasco
  • 3
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 24 '21 at 18:19

1 Answers1

0

This query expression will return the name of the pods with their corresponding age, that are running more than 90 days.

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

and this one will return the name of the pods that have been run in the last 90 days. Note there can be exited pods also, that doesn't exist now.

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

Hayk Davtyan
  • 128
  • 1
  • 1
  • 7