我们对某些事件有splunk索引。事件按事件类型分类。
我需要找到固定大小(比方说,5分钟)窗口,其中任何事件的频率(每秒事件数)与前一个窗口相比下降/上升超过预设百分比(比如50%)。 / p>
我没有成功,尝试过这样的事情:
index=index_of_events | eval cnt=1 | timechart span=20s limit=40 per_second(cnt) as ev by ev_type useother=f usenull=f |
streamstats window=40 global=false first(ev) as start last(ev) as end by ev_type |
eval diff=abs(start-end) | eval max_val=max(start, end) |
where diff > 0 AND max > 0 | eval prc=100*diff/max_val | where prc > 50
它接近可行吗?我可以将timechart
直接发送到streamstats
,还是我需要untable
之间的内容?
有没有更好的方法来完成这样的任务?
如果可能,我还想排除低频事件(如果2/sec
变为1/sec
,则不在乎。)
答案 0 :(得分:0)
通常时间表最好留到最后,尝试使用统计数据
(删除//评论)
search ...
// group by type
| stats count by type
// establish a 'normal'
| streamstats window=5 global=f median(count) as floating_median by type
// calculate delta
| eval diff = count-floating_median
| eval diff_percent = diff/floating_median
// find outliers
| eventstats max(diff_percent) as diff_percent_max by type
| where diff_percent_max > 0.5
// visualise
| timechart sum(count) as count by type