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!

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Community Feedback

We Want to Hear from You! Share Your Feedback on the Splunk Community   The Splunk Community is built for you ...

Manual Instrumentation with Splunk Observability Cloud: Implementing the ...

In our observability journey so far, we've built comprehensive instrumentation for our Worms in Space ...