Splunk Rex:将字符串的字段提取为值

时间:2019-11-19 17:50:03

标签: splunk splunk-query splunk-formula rex splunk-sum

我是SPlunk的新手,试图做一些仪表板,并且需要帮助来提取特定变量的字段

在我的情况下,我只想将KB_List“:” KB000119050,KB000119026,KB000119036“的值提取到列中

Expected output:

KB_List
KB000119050,KB000119026,KB000119036

我尝试过:

| rex field=_raw "\*"KB_List":(?<KB_List>\d+)\*"

突出显示了日志中的以下部分

  

svc_log_ERROR”,“ Impact”:4.0,“ CategoryId”:“ 94296c474f356a0009019ffd0210c738”,“ hasKBList”:“ true”,“ lastNumOfAlerts”:1,“ splunkURL”:false,“ impactedInstances”:“”,“最高优先级” :“次要”,“源”:“ hsym-plyfss01”,“ reqEmail”:“ true”,“ AlertGroup”:“ TIBCOP”,“ reqPage”:“”,“ KB_List”:“ KB000119050,KB000119026,KB000119036”, “ reqTicket”:“ true”,“ autoTicket”:true,“ SupportGroup”:“ TESTPP”,“ Environment”:“ UAT”,“ Urgency”:4.0,“ AssetId”:“ AST000000000159689”,“ LiveSupportGroup”:“ TESTPP “,” sentPageTo“:” TESTPP“},” Notification“:{”“:{” requestId“:” 532938335“}},”“:

2 个答案:

答案 0 :(得分:1)

rex field=_raw "KB_List\":\"(?<KB_List>[^\"])\""

此正则表达式将查找以KB_List":"开头的所有内容,捕获除"以外的所有内容。

在您的示例中,您仅捕获数字(\d+),而KB_List字段中的内容还包含字符(“ KB”和“,”)

答案 1 :(得分:0)

A:

我看了很多文章才知道:

| rex "KB_List\":\"(?<KB_Listed>[^\"]+)" | table KB_Listed