【发布时间】:2017-02-14 18:01:24
【问题描述】:
我的 splunk 数据中有两个字段,称为“impact_time”和“incident_name”。现在我想根据“impact_time”和我给出的跨度来聚合这些事件名称。例如, 如果我给跨度为 1d,它应该聚合每个日期下的事件。
2016-06-28 a,b,c,d
2016-06-29 g,r,w,d
2016-06-30 f,e,r,t
如果我将跨度指定为 1 小时,它应该从影响时间开始以小时为基础进行汇总
2016-06-28 03:00:00 a,b,c,d
2016-06-29 04:00:00 g,r,w,d
2016-06-30 05:00:00 f,e,r,t
我通过以下查询得到这个:-
index=sn impact=1 OR impact=2 | eval time = round( strptime(impact_start,"%Y-%m-%d %H:%M:%S"), 0 )| where time >= ' + timeStart + ' AND time<=' + timeEnd + '| bucket time span=' + hm + ' | stats values(number) as incident_name by time
但是有一个问题。当我将聚合时间保持为“小时”时,如果一个小时没有数据,它不会显示该“影响时间”的任何内容。如中,数据表中完全缺少相应的 Impact_time。如果“impact_time”中没有要显示的数据,有什么方法可以为“impact_time”显示一个空的“incident_number”字段?例如:-
2016-06-28 03:00:00 a,b,c,d
2016-06-29 04:00:00 g,r,w,d
2016-06-30 05:00:00 f,e,r,t
2016-06-30 08:00:00 f,e,r,t
这里时间 06:00:00、07:00:00 没有数据。因此,数据输出中完全缺少这些字段,而不是显示:-
2016-06-28 03:00:00 a,b,c,d
2016-06-29 04:00:00 g,r,w,d
2016-06-30 05:00:00 f,e,r,t
2016-06-30 06:00:00 (null or empty)
2016-06-30 07:00:00 (null or empty)
2016-06-30 08:00:00 f,e,r,t
提前致谢。
【问题讨论】:
标签: aggregation timespan splunk bucket