连接两个没有预定义字段的 Splunk 查询
Join two Splunk queries without predefined fields
我正在尝试加入 2 个 splunk 查询。但是,在这种情况下,两个查询之间的公共字符串不是预定义的 splunk 字段,而是以不同的方式记录的。我已经创建了单独标识字符串的正则表达式,但是当我尝试使用 join 进行组合时,我没有得到结果。
我有这样的日志 -
故事情节 1 -
21-04-2019 11:01:02.001 server1 app1 1023456789 1205265352567565 1234567Z-1234-1234-1234-123456789123 Application Completed
故事情节 2 -
21-04-2019 11:00:00.000 journey_ends server1 app1 1035625855585989 .....(lots of text) commonID:1234567Z-1234-1234-1234-123456789123 .....(lots of text) status(value) OK
第二个Logline也可以是NOTOK
故事情节 2 -
21-04-2019 11:00:00.000 journey_ends server1 app1 1035625855585989 .....(lots of text) commonID:1234567Z-1234-1234-1234-123456789123 .....(lots of text) status(value) NOTOK
我尝试了很多东西,但我能想到的最好的是 -
index=test "journey_ends" | rex "status(value) (?<StatusType>[A-Z][A-Z]*)" | rex "commonID\:(?<commonID>[^\t]{37})" | table StatusType, commonID | join type=inner commonID [ search index=test "Application Completed" | rex "^(?:[^\t\n]*\t){7}(?P<commonID>[^\t]+)" | table _time, commonID] | chart count over StatusType by commonID
但是上面的查询没有提供统计信息。在详细模式下,我只能看到查询 1 的事件。请注意,以上 2 个查询 运行 分别正确。
但是目前我必须首先 运行 查询从 "Application Completed" 日志行中获取 commonID,然后在另一个查询中给出在结果第一个查询中找到的 commonID 列表作为输入并找到日志行 2 中每个 commonId 的状态值。
预期结果(table):
StatusType commonID OK 1234567Z-1234-1234-1234-123456789123 NOTOK 1234567Z-1234-1234-1234-985625623541
你能试试下面的查询吗,
index=main
AND "Application Completed"
| rex "(?<common_id>[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+)"
| table _time, common_id
| join type=inner common_id [
search index=main
| rex "status\(value\)\s+(?<status>.+)$"
| rex "(?<common_id>[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+)"
| table status, common_id
]
我正在尝试加入 2 个 splunk 查询。但是,在这种情况下,两个查询之间的公共字符串不是预定义的 splunk 字段,而是以不同的方式记录的。我已经创建了单独标识字符串的正则表达式,但是当我尝试使用 join 进行组合时,我没有得到结果。
我有这样的日志 -
故事情节 1 -
21-04-2019 11:01:02.001 server1 app1 1023456789 1205265352567565 1234567Z-1234-1234-1234-123456789123 Application Completed
故事情节 2 -
21-04-2019 11:00:00.000 journey_ends server1 app1 1035625855585989 .....(lots of text) commonID:1234567Z-1234-1234-1234-123456789123 .....(lots of text) status(value) OK
第二个Logline也可以是NOTOK
故事情节 2 -
21-04-2019 11:00:00.000 journey_ends server1 app1 1035625855585989 .....(lots of text) commonID:1234567Z-1234-1234-1234-123456789123 .....(lots of text) status(value) NOTOK
我尝试了很多东西,但我能想到的最好的是 -
index=test "journey_ends" | rex "status(value) (?<StatusType>[A-Z][A-Z]*)" | rex "commonID\:(?<commonID>[^\t]{37})" | table StatusType, commonID | join type=inner commonID [ search index=test "Application Completed" | rex "^(?:[^\t\n]*\t){7}(?P<commonID>[^\t]+)" | table _time, commonID] | chart count over StatusType by commonID
但是上面的查询没有提供统计信息。在详细模式下,我只能看到查询 1 的事件。请注意,以上 2 个查询 运行 分别正确。
但是目前我必须首先 运行 查询从 "Application Completed" 日志行中获取 commonID,然后在另一个查询中给出在结果第一个查询中找到的 commonID 列表作为输入并找到日志行 2 中每个 commonId 的状态值。
预期结果(table):
StatusType commonID OK 1234567Z-1234-1234-1234-123456789123 NOTOK 1234567Z-1234-1234-1234-985625623541
你能试试下面的查询吗,
index=main
AND "Application Completed"
| rex "(?<common_id>[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+)"
| table _time, common_id
| join type=inner common_id [
search index=main
| rex "status\(value\)\s+(?<status>.+)$"
| rex "(?<common_id>[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+-[[:alnum:]]+)"
| table status, common_id
]