Filter Splunk如何从列表中排除某个值(如果存在)

Filter Splunk如何从列表中排除某个值(如果存在),filter,splunk,splunk-query,splunk-formula,splunk-sum,Filter,Splunk,Splunk Query,Splunk Formula,Splunk Sum,我有一个日志,上面有如下内容: "Stats":[ { errors: 0 type: "Disc" success: 878 }, { errors: 21 type: "cronJob" success: 25 },

我有一个日志,上面有如下内容:

"Stats":[        { 
           errors: 0
           type: "Disc"
           success: 878
         },
         {
           errors: 21
           type: "cronJob"
           success: 25
         },
         { 
           errors: 0
           type: "File"
           success: 8787
         },
         { 
           errors: 15
           type: "Unknown"
           success: 0
         }]
index=ndx sourcetype=srctp Stats{}.type=*
| rename Stats{}.type as type
| mvexpand type
| search NOT type="Unknown"
| ...
我需要去掉“未知”类型的对象,并得到剩余值的总和

我能够得到所有错误的总和,但对于类型未知的事件,我不知道如何做到这一点。你能帮忙吗

<search>|rename Stats{}.type= as type|eventstats sum(errors)  as ErrorCount 
|将Stats{}.type=重命名为type |将eventstats sum(errors)重命名为ErrorCount
这是我目前的搜索,不排除未知类型。如何合并逻辑以排除未知计数

|重命名Stats{}.type=as type | where type!=“未知”|事件统计和(错误)作为错误计数
<search>|rename Stats{}.type= as type | where type != "Unknown" | eventstats sum(errors)  as ErrorCount 

JSON负载被视为一个多值字段

因此,在筛选出要忽略的内容之前,您需要展开它

试着这样做:

"Stats":[        { 
           errors: 0
           type: "Disc"
           success: 878
         },
         {
           errors: 21
           type: "cronJob"
           success: 25
         },
         { 
           errors: 0
           type: "File"
           success: 8787
         },
         { 
           errors: 15
           type: "Unknown"
           success: 0
         }]
index=ndx sourcetype=srctp Stats{}.type=*
| rename Stats{}.type as type
| mvexpand type
| search NOT type="Unknown"
| ...

请不要只发布代码作为答案,还要解释代码的作用以及它是如何解决问题的。带有解释的答案通常更有帮助,质量更好,并且更有可能吸引选票。这不起作用-它将消除所有在
Stats{}.type
字段中具有“未知”的事件。。这不是你想要的。您不能将Stats{}.type=重命名为type——您将得到一个语法错误。