Use case
I am creating a tool to show the resource requests of all pods in a kubernetes cluster. Prometheus already scrapes my prometheus metric exporter and historically saves all the scraped metrics (interval 10s), so that I could even see the resource requests from all pods 10 days ago.
The problem
Every time a pod has been redeployed it does change the name. However I only want to show the resource requests of actually RUNNING pods. For this purpose I could obviously add a time selector like, show me only max 15s old results, but that would be a little hack. If possible I'd like to get the results from the latest scrape iteration (which in case of problems could be older than 15s).
The question
What's the best way to get only those prometheus metrics which have been scraped in the last iteration?
eagle_container_resource_requests_cpu
for instance would return the requested CPU cores of pods which nowadays no longer exist.
Side note: I am trying to achieve this behaviour in a Grafana table.