首页 > 解决方案 > Splunk 搜索问题

问题描述

我有一个如下的搜索查询。

index = abc_dev sourcetype = data RequestorSystem = * Description="Request Receieved from Consumer Service" 
  OR Description="Total Time taken in sending response"
| dedup TId
| eval InBoundCount=if(Description="Request Receieved from Consumer Service",1,0)
| eval OutBoundCount=if(Description="Total Time taken in sending response",1,0)
| stats sum(InBoundCount) as "Inbound Count",sum(OutBoundCount) as "Outbound Count"

我不确定为什么入站计数始终显示为 0,出站计数工作正常

标签: splunk

解决方案


您的eval InBoundCount=... Received中有一个拼写错误,如果您的事件拼写正确,它将不匹配!

如果不是这样:

  1. 尝试分别对这两个计数运行查询,并确保您收到事件。此外,发布一些示例输入事件将使我们的答案更加准确。

  2. Splunk 查询由隐式连接,AND这意味着您OR需要包含在括号中或(如果您使用的是 Splunk 6.6 或更高版本)使用如下IN关键字:

    index = abc_dev sourcetype = data RequestorSystem = * Description IN ("Request Receieved from Consumer Service", "Total Time taken in sending response")

如果您以后想添加其他字符串,则使用IN更便携。通过一些调整,您甚至可以使用stats count by Descriptionthis 的变体。


推荐阅读