Ok, I tried to rewrite the problem here:
This is a different approach to the problem I’m having. I was hoping I could just run a psql query, get the string I needed, and then feed it into the prometheus query because the chained variables get tricky and I lose track.