【问题标题】:Splunk command to check if current search is greater than x% of previous searchSplunk 命令检查当前搜索是否大于先前搜索的 x%
【发布时间】:2020-09-30 18:49:49
【问题描述】:

我想知道如何在 Splunk 中编写搜索查询,以检查当前搜索是否大于先前搜索的 20%。我每 10 分钟就会收到一次特定计数的事件。我想检查我的当前计数(过去 10 分钟)是否大于我之前计数(过去 20 分钟)的 20%。我需要使用子搜索进行比较。但没有得到结果。有人可以帮忙吗?

【问题讨论】:

  • 您的数据是什么样的?到目前为止,您尝试过什么?

标签: splunk splunk-query splunk-formula splunk-calculation


【解决方案1】:

我建议将搜索结果保存到摘要索引中。然后,您可以单独搜索处​​理摘要索引,以查找结果是先前结果的 120% 的实例。

要将您的搜索结果保存到摘要索引中,请将| collect <summary> 添加到您现有的搜索中。 <summary> 是将接收搜索结果的现有索引的名称。

将处理摘要的搜索可以使用streamstats 命令来处理事件。

index=summary 
`comment("Change 'head' to 'tail' if the events are in reverse order")`
| head 2
`comment("Get the difference between the current value and the previous one")`
| streamstats range(foo) as diff
`comment("We don't know the previous value of foo so we need to work 'backward' to see if the current value is too big")`
| where (foo - diff) > (foo * 0.833)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 2017-04-18
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    相关资源
    最近更新 更多