如何在 splunk 中使用多个分隔值提取数据

How to extract data using multiple delimited values in splunk

我在带有多个分隔符(:= 和#)的日志中有以下字符串。我期待表格格式中的所有值,如

 tenant |countryCode |deviceType |platformID|paymentMethod1|paymentMethod2|userAgent
 XYZ    | US         | IOS        |13        |p1            |p2            |Mozilla /20.0.553 Mozilla/5.0      

记录字符串

TrackingLogs tenant=XYZ, countryCode=US, deviceType:IOS, platformID:13,currency=USD, paymentMethods:P1 # P1 # P2 # P2 # P4 # , userAgent:Mozilla /20.0.553 Mozilla/5.0

我尝试了 ':' 但没有结果

search string| rex field=_raw "deviceType\:\s+?(?<deviceType>\S+)" |table  deviceType

for = 我使用下面的查询它有效但不知道如何将它与 : 和 #

结合使用
search trackinglog  | rex field=tenant "(?<tenant>[^\.]*)\.[a-zA-Z]"| table _raw tenant, countryCode , currency , paymentMethods

第一个查询的问题不是分隔符,而是正则表达式本身。它期望存在 none 的 space。此变体有效:

| rex field=_raw "deviceType:\s*?(?<deviceType>\S+)" |table  deviceType

但是,为了获得更好的结果,请尝试 extract 命令。

| extract pairdelim="," kvdelim=":="