Using pattern and then filtering by label values

We just started using Loki instead of fluentbit. I came across using pattern for splitting logs to labels, and that too many labels means too much space. So it makes sense to have labels only when needed. However, I couldn’t find a way to apply pattern in logQL, and then filter on the parsed labels.

Any pointers to the documentation/examples is very welcome!