Getting Data In

Props.confで、タイムスタンプに時間修正を加えて_timeに格納できない

splunklover
Observer

複数の時間が入っているログから、特定のフィールドのタイムスタンプを一つを選択し、時間を変更した上で、タイムスタンプ(_time)に格納したいのですが、
うまくできません。
例えばログは以下の様なものです。

580 <158>1 2020-06-26T13:03:36+09:00 logforwarder x - - test 1,2020/06/26 04:03:30,no-serial,TRAFFIC,end,2304,2020/06/26 04:03:11,,,,,

Splunk上では、2020-06-26T13:03:36+09:00の値が_timeに入っています。
しかし、この値を_timeに格納したいのではなく、上記ログの2020/06/26 04:03:30に+9時間を足した値を_timeとしたいです。
2020/06/26 04:03:30はgenerated_timeというキーに入っています。

Props.confでは以下の処理を定義しましたが、うまくいきませんでした。

EVAL-temptime = strptime(generated_time,"%Y/%m/%d %H:%M:%S")
EVAL-temptime2 = strftime(temptime+(32400),"%Y/%m/%d %H:%M:%S")
FIELDALIAS-time = temptime2 AS _time

Props.confでは上記の様なEVAL処理はできないのでしょうか。
サーチ文としては動作することは確認していて、以下のコマンドでは、正常に_timeにgenerated_timeに+9時間したものが格納されます。

|eval temptime = strptime(generated_time,"%Y/%m/%d %H:%M:%S") | eval _time=strftime(temptime+(32400),"%Y/%m/%d %H:%M:%S") | stats count by _time

Labels (2)
Tags (1)
0 Karma

to4kawa
Ultra Champion

@splunklover 

https://qiita.com/toshikawa/items/adfd3c565b18b3fa7814

リンク先は趣旨が違いますが、やり方の参考として

transforms.confのINGEST_EVALが使えます

| eval _time=strptime(generated_time."+0900","%Y/%m/%d %H:%M:%S%z")
UTCからJSTだと、こちらの変換はいかがですか?

 

と書いたあとで訂正。

props.conf:

TIME_PREFIX = .*?,
TZ = UTC

でいかがですか?
_time に格納するのであれば、ログのフィールド抽出で調整したほうがいいですね。

 

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

April 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...