0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Splunkの_timeの中はepochだけど、strftimeで変換したら文字列だよ

Posted at

 概要

表題そのまま

検証

SPL
| makeresults
| eval time=_time-1.000000000
| eval Time=strftime(time,"%Y-%m-%dT%H:%M:%S.%9Q")
| eval dur = _time - time

いつものmakeresultsから、自動的に__time_が作られるので1秒前の時間を_time_として
_TIME_を見やすい形で作る。
_dur_で差分確認

結果

QIITA1.png

_time_がepochになっているのがよくわかり、差分である_dur_も9桁・ナノセコンドを表せてる。

実験

SPL
| eval dur2 =_time - Time

Qiita2.png
_dur2_がでない。

SPL
| makeresults
| eval time=_time-1.000000000
| fieldformat Time=strftime(time,"%Y-%m-%dT%H:%M:%S.%9Q")
| eval dur = _time - time
| eval dur2 = _time - Time

Qiita4.png

evalじゃなきゃいけるかとおもったらダメだった。

結言

__time_の中はepochなのでevalとかで他のフィールドに代入しちゃうと人間がよくわからない値になっちゃうけど、計算はそのままやってしまわないといけないってことですね。
convertとかrelative_timeとか。

:sweat: Rみたく、$date1 - $date2 で差分が綺麗にでてくれないかしら

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?