In Loki, I have logs output by the .NET Entity Framework that include duration as a number of milliseconds. If the number is 1000 or greater, the output includes a comma, like in the example below:
2024-08-11T04:10:49.92983505Z stdout F Executed DbCommand
(3,768ms) [Parameters=[@__param_0=’?’ (DbType = Object), @__param_2=’?’ (DbType = Object), @__param_3=’?’ (DbType = Object),
@__param_4=’?’ (DbType = Object)], CommandType=’Text’,
CommandTimeout=’30’]
I extract the duration using a regex filter with a query like the following:
{container="my-container"} |= `Executed DbCommand` != " INFO " | regexp `((?P<query_ms>[0-9]+,?[0-9]*ms))
This works great, and I’m able to see the value as a string. But if I try to filter the duration, e.g. by adding | query_ms > 30s
to the query, any line containing a comma gets a label format error.
I’ve also tried leaving the ms out of the text captured by the regex and looking for values greater than 30000, but this has the same issue
How can I extract a value containing a comma and have Loki treat it as a number?