Prometheus rename legend AND run alerts - possible?

Hello, I am trying to run alerts on prometheus query, and at the same time have meaningful legend. It seems to me that if I want to use a field name for a legend, I need to use a transform, and alerts cannot be defined for a query using transforms. Is it possible for me to change legend names some other way?
My data looks like so (a lot of fields removed to make it more readable):

{instance="exporter.example.com:3020",job="kafka-metrics",topic="Topic_A"}
{instance="exporter.example.com:3020",job="kafka-metrics",topic="Topic_B"}

I would like to have legend say “Topic_A” and “Topic_B” instead of the whole query result, and then, at the same time, alert on high values. “Labels to fields” transformation allows me to change legend, but breaks alerts. Is there any way I can both change legend and have my alerts?
Thank!