Skip to main content
Question

Identifying a timestamp inside of JSON

  • March 11, 2025
  • 22 replies
  • 19 views

Shawn Cannon
Forum|alt.badge.img

I have a timestamp field inside JSON in the format "2023 April 18 15:00:00 UTC". I cannot get Stream to recognize it. It keeps using current time. Any ideas?

22 replies

What's your event breaker configured as?


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

unfortunately that event comes in via syslog (I know, stupid but that is how it comes in) so no event breaker


David Maislin

`%Y %B %d %H:%M:%S`?


David Maislin

Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

i have tried a time format as well to no avail. I was thinking the UTC at the end was doing it. I will keep trying stuff.


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

its weird as I have the event in JSON format and I can see the field _raw.Alert.timestamp. I try to apply that field as my auto timestamp and it does not use it. just a strange one.


David Maislin

That timestamp format I used works for me.


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

yeah i dont know whats up


  • Known Participant
  • March 11, 2025

Have you tried Auto Timestamp + setting an Additional Timestamp regex?I had to use this method for something that I think should worked out-the-box with the AWS event breaker ruleset.


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

I did try that and it still did not work.


  • Known Participant
  • March 11, 2025

Maybe the timestamp is quite ahead in the event, in the auto time stamp function, under advanced you can increase this setting to make it look further


David Maislin

It was basically this Eval Function that fixed the issue with time:


David Maislin

```_raw = JSON.parse(_raw)_time = +C.Time.strftime(C.Time.strptime(_raw.Alert.timestamp,'%Y %B %d %H:%M:%S'),'%s')```


David Maislin

You have to first parse the JSON string into an Object, then you can refer to the exact fieldname `_raw.Alert.timestamp` and pull out the time based on the format of the timestamp.


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

Thanks for posting, got busy and forgot.


David Maislin

IN & OUT


David Maislin

Thanks for providing clean data so I can share the summary easier :slightly_smiling_face:


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

Always happy to help


David Maislin

Same expression can also be used in AutoTimeStamp but you have to know the length of the event to know how raw to look. Funny I started with 500 with the Start Scan Offset as a guess to the length of the event and it was 716. It didn't look that big to my eyes honestly.Start Scan Offset


Shawn Cannon
Forum|alt.badge.img
  • Author
  • Known Participant
  • March 11, 2025

Nice


David Maislin

You can also adjust the Max Timestamp Scan Depth too!


David Maislin

But now you see why I like to convert to an object because I don't always wanna guess the event length as the timestamp can be anywhere in the event in some cases.