【问题标题】:Splunk Convert Epoch milliseconds to Human Readable Date formatting issueSplunk 将 Epoch 毫秒转换为人类可读日期格式问题
【发布时间】:2015-07-24 02:58:20
【问题描述】:

我关注 Splunk Query,它试图将 Epoch 捕获的开始和结束时间格式化为人类可读的格式,但似乎 splunk 在这里提取了不正确的值...

index=wd_test source=*-1.0.0.log 
| fieldformat c_start=strftime(start,"%m/%d/%Y %H:%M:%S") 
| convert timeformat="%m/%d/%Y %H:%M:%S" ctime(end) as c_end 
| eval duration=(end-start)/1000
| table start, c_start, end, c_end , duration, sla

作为执行上述查询的一部分,我得到以下结果

start   c_start end c_end   duration    sla
1   1430167363808   12/31/9999 23:59:59 1430167364085   12/31/9999 23:59:59 0.277000    2  
2   1430167236667   12/31/9999 23:59:59 1430167236856   12/31/9999 23:59:59 0.189000    2

有人可以帮我解决这个问题吗?我在这里尝试了 2 种不同的方法,但都没有奏效。

使用以下 Online Epoch 格式的工具我能够成功转换,但不能使用 Splunk...

http://www.freeformatter.com/epoch-timestamp-to-date-converter.html

【问题讨论】:

    标签: epoch splunk


    【解决方案1】:

    我尝试对此问题进行调查,结果似乎 Splunk 不支持 13 位 EPOCH 时间,Splunk API 仅支持 10 位 EPOCH。因为我无法使用 13 位数字,当我将 13 位数字更改为 10 位数字时,它对我来说效果很好。

    【讨论】:

      【解决方案2】:
      index=wd_test source=*-1.0.0.log 
      | fieldformat c_start=strftime(start,"%m/%d/%Y %H:%M:%S") 
      | convert timeformat="%m/%d/%Y %H:%M:%S" ctime(end) as c_end 
      | eval duration=***round***(end-start)/1000
      | table start, c_start, end, c_end , duration, sla
      

      ***round***(end-start)/1000之前添加圆

      纪元时间基于秒,而不是毫秒

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-02
        • 1970-01-01
        • 2012-06-16
        • 2010-09-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-25
        相关资源
        最近更新 更多