[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

You ever figure this out? I’m having the exact issue. I have a simple string in a field and the string always begins with something like “Tier 1” or “Tier 2”. I have the regex of “(Tier [0-9])” but it just always returns the entire string. It honestly doesn’t seem to matter what I put in the RegExp field. It just creates a new field with the entire value of the original field no matter what…

Driving me nuts…

For me to get anything to work, I had to make sure I was doing a named capturing group. See New regular expression option for Extract fields transformation | Grafana Labs and click through to the mozilla documentation. e.g., (?yourregex)