Kubernetes: Comparing RSS Memory Usage of Pods and Pod Memory Requirements in Prometheus / PromQL
You can use the label_replace function to modify labels on one side of the expression such that they match:
sum by (pod_name, namespace) (container_memory_rss) / sum by (pod_name, namespace) ( label_replace( kube_pod_container_resource_requests_memory_bytes, "pod_name", "$1", "pod", "(.*)" ) )