我有一些CSV数据关于导入到Splunk的文件。数据如下:
"\\domain\path\to\file\","<filename>","<fsize>","<ext>","<Last_access>","<last_write>","<creation_time>","<attributes>","<owner>"我已经使用以下方法将所有日期字符串转换为纪元:
| eval epoch_LastAccessTime=strptime(LastAccessTime, "%d/%m/%Y %H:%M:%S")
...
...我想要:
这是我在陷入困境之前尝试过的搜索查询:
index="<my_index>" sourcetype="<my_sourcetype>"
| rex field=DirectoryName "\\\domain\.org\\\teams\\\(?<Team>[^\\\]*)"
offset_field=_extracted_fields_bounds
| eval epoch_LastAccessTime=strptime(LastAccessTime, "%d/%m/%Y
%H:%M:%S")
| eval _time=epoch_LastAccessTime
| timechart span=6mon count我试过使用以下命令:
| where epoch_LastAccessTime>=three_year_ago_from_now AND
epoch_LastAccessTime<=six_months_ago_from_now然而,这不包括其他一切(3y+)
我希望结果看起来像:
TimeRange Perc
6m-3y 60%
3y+ 40%发布于 2018-03-19 17:00:29
信贷:洛厄尔
与其使用where来限制结果,不如使用eval构建一个新的分类字段。
那样的话,你就不再需要时差了。
类似于:
| eval TimeRange=case(epoch_LastAccessTime>=three_year_ago_from_now, "3y+",
epoch_LastAccessTime>=six_months_ago_from_now, "6m-3y",
0=0, "less than 6m")
| stats count by TimeRange
| eventstats sum(count) as total_count
| eval pct=100*count/total_counthttps://stackoverflow.com/questions/49361947
复制相似问题