我想知道如何在 Splunk 中编写搜索查询,以检查当前搜索是否大于先前搜索的 20%。我每 10 分钟就会收到一次特定计数的事件。我想检查我的当前计数(过去 10 分钟)是否大于我之前计数(过去 20 分钟)的 20%。我需要使用子搜索进行比较。但没有得到结果。任何人都可以帮忙吗?
问问题
274 次
1 回答
0
我建议将搜索结果保存到摘要索引中。然后,您可以单独搜索处理摘要索引,以查找结果是先前结果的 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)
于 2020-09-30T21:56:47.287 回答