Сross-request in query legend

Hi everyone!

I have several query graphs that receive data from Prometheus. They show information from different docker nodes, but the only information I can get from the query to set it in the Legend field is instance IP. This instance IPs are incomprehensible to a simple user. Therefore, I want to change Legend field values by using some other query in which I can find docker node name. I have such query, where I can find one Node name for one instance IP. But I have no idea how to put it all together.

So, here a real queries example:

  1. Graph query:

100 - (avg by (instance) (irate(node_cpu_seconds_total{instance=~"$node",mode=“idle”}[5m])) * 100)

  1. The only Legend for this query:


  1. The query, where I can find a good name (used in variables):


Is there any way to set a cross-request in a Legend field inside a query?