首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >扣篮条件计数

扣篮条件计数
EN

Stack Overflow用户
提问于 2018-03-19 11:31:39
回答 1查看 3K关注 0票数 1

我有一些CSV数据关于导入到Splunk的文件。数据如下:

代码语言:javascript
复制
"\\domain\path\to\file\","<filename>","<fsize>","<ext>","<Last_access>","<last_write>","<creation_time>","<attributes>","<owner>"

我已经使用以下方法将所有日期字符串转换为纪元:

代码语言:javascript
复制
| eval epoch_LastAccessTime=strptime(LastAccessTime, "%d/%m/%Y %H:%M:%S")
...
...

我想要:

  • 上次访问的文件百分比是6个月到3年前
  • 最近一次访问文件的百分比是3年前或更久以前。

这是我在陷入困境之前尝试过的搜索查询:

代码语言:javascript
复制
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

我试过使用以下命令:

代码语言:javascript
复制
| where epoch_LastAccessTime>=three_year_ago_from_now AND 
epoch_LastAccessTime<=six_months_ago_from_now

然而,这不包括其他一切(3y+)

我希望结果看起来像:

代码语言:javascript
复制
TimeRange  Perc
6m-3y      60%
3y+        40%
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-19 17:00:29

信贷:洛厄尔

与其使用where来限制结果,不如使用eval构建一个新的分类字段。

那样的话,你就不再需要时差了。

类似于:

代码语言:javascript
复制
| 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_count
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49361947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档