PromSQL to get the labels of the latest created pod of a kubernetes deployment

Hi all,

I would like to join the metric kube_deployment_status_observed_generation with the metric kube_pod_container_info, so that I can have the label image as a additional label in kube_deployment_status_observed_generation.

I created the following PromQL:

( 
  kube_deployment_status_observed_generation{namespace="default", deployment="myapp"}
)
+ on(namespace) group_left(image)
(
  kube_pod_container_info{namespace="default",container="myapp"}
)

This is working fine if a deployment has only one pod. If not, I am getting an many-to-many matching not allowed error because the metric kube_pod_container_info is returning more than one value.

Since the value of the image of the latest created pod will be sufficient I could do something like this:

(
  kube_deployment_status_observed_generation{namespace="default", deployment="myapp"}
)
+ on(namespace) group_left(image)
(
 max(kube_pod_start_time{pod=~"myapp-.+"})
+ on(pod) group_left(pods)
kube_pod_container_info{container="myapp"}
)

But this is not working since the metric max(kube_pod_start_time{pod=~"myapp-.+"})` is not returning the labels of the entity and therefore a join is not possible.

How can I join these two metrics?