我有这样的日志:
I, [2020-06-17T09:32:48.100103 #9] INFO -- : [54b35e04-9c19-443d-adff-b2c3192b5590] Completed 500 Internal Server Error in 7ms (ActiveRecord: 2.3ms | Allocations: 1705)
I, [2020-06-17T10:37:27.169909 #9] INFO -- : [c800e9ce-fba3-4e1a-a19f-526f32746925] Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms | Allocations: 115)
因此,正如您在消息中看到的那样,它始终遵循以下模式: Completed [THE ERROR CODE] [ERROR MESSAGE] ...
我正在使用此查询来检索具有某些错误代码的日志:
fields @timestamp, @message
| filter @message like /401/
| sort @timestamp desc
| limit 20
但是如何解析消息以获取错误代码和消息的单独字段?