[Loki + Grafana] Extract Fields Regex Not Working — Log Line Includes ANSI Color Codes

Hi everyone,

I’m trying to visualize response times from logs in a Grafana time series panel using Loki. My log lines come from a NestJS app and look like this (with ANSI color codes for terminal coloring):

[32m[Nest] 1275414  - e[39m04/11/2025, 9:35:12 PM e[32m    LOGe[39m e[38;5;3m[Response] e[39me[32mGET /api/v1/webhook/prod 200 551mse[39m

I added an “Extract fields” transform and used this regex/few different regex to get the duration:

(\d+)ms

But it doesn’t extract anything — the output is always the full log line, not the match group.

Thanks in advance!

Try decolorize and pattern parser on the LogQL level