Splunk登录中的正则表达式进行搜索

问题描述 投票:0回答:1

我有Splunk日志,其条目如下所示:

15/01/2020
10:34:29.076    
{ [-]
   app_module: testmodule
   environment: XXXX
   level:  INFO
   logger_name:                      project.stats
   message: Query execution time: [1222] app ID: [TEST] for user: [jhhsakjhsa]
   thread_name:    catalina-exec-371
   timestamp: 2020-01-15T05:04:29,076
   x-request-id: hdkhwqkjdhwqhdwqdo908109328182eh
}
Show as raw text
host = <host>,worker, Splunk--idx-d-i-0xssaxx4d0f95a8timestamp = 2020-01-15T05:04:29,076 

我需要进行查询,查询执行时间以4位数字表示。我们在splunk日志的消息字段中将查询执行时间作为日志语句(查询执行时间:[1222]

将要查询的内容。

splunk splunk-query
1个回答
0
投票

以下内容将创建一个新字段,称为query_exec_time

rex field=_raw "Query execution time: [(?<query_exec_time>\d+)]"

所以您的搜索可能看起来像下面的内容

index=<...> | rex field=_raw "Query execution time: [(?<query_exec_time>\d+)]" | where query_exec_time > 999

或者,您也可以使用regex

index=<...> | regex _raw="Query execution time: [\d{4})]"
© www.soinside.com 2019 - 2024. All rights reserved.