Getting Data In

Parsing Multi Line Timestamp

jroedel
Path Finder

I have to parse the timestamp of JSON logs and I would like to include subsecond precision. My JSON-Events start like this:

 

 

{
  "instant" : {
    "epochSecond" : 1727189281,
    "nanoOfSecond" : 202684061
  },
...

 

 

 

Thus I tried as config in props.conf:

 

TIME_FORMAT=%s,\n    "nanoOfSecond" : %9N
TIME_PREFIX="epochSecond" :\s
MAX_TIMESTAMP_LOOKAHEAD=500

 

 

That did unfortunately not work.

 

What is the right way to parse this time stamp with subsecond precision?

Labels (3)
0 Karma
1 Solution

jroedel
Path Finder

Finally after a lot of testing I found a solution via transforms.conf

 

[timestamp-fix]
INGEST_EVAL= _time=json_extract(_raw,"instant.epochSecond").".".json_extract(_raw,"instant.nanoOfSecond")

 

Furthermore, it turned out that regex is not allowed in TIME_FORMAT field in props.conf.

View solution in original post

jroedel
Path Finder

Finally after a lot of testing I found a solution via transforms.conf

 

[timestamp-fix]
INGEST_EVAL= _time=json_extract(_raw,"instant.epochSecond").".".json_extract(_raw,"instant.nanoOfSecond")

 

Furthermore, it turned out that regex is not allowed in TIME_FORMAT field in props.conf.

gcusello
SplunkTrust
SplunkTrust

Hi @jroedel ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jroedel ,

are you sure about the number of spaces?

please try this:

TIME_FORMAT=%s,\n\s*"nanoOfSecond"\s*:\s*%9N
TIME_PREFIX="epochSecond"\s*:\s*
MAX_TIMESTAMP_LOOKAHEAD=500

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jroedel ,

please try this:

TIME_FORMAT=%s,\n\s*\"nanoOfSecond\"\s*:\s*%9N
TIME_PREFIX=\"epochSecond\"\s*:\s*
MAX_TIMESTAMP_LOOKAHEAD=500

Ciao.

Giuseppe

0 Karma

jroedel
Path Finder

Thanks for your second attempt. I tried, but still no luck.

Might there be the possibility, that the "Add Data" WebUI Wizard does not support this correctly?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jroedel ,

if the Add Data feature doesn't permit to use this feature I suppose that it isn't possible event if it's strange.

I tried but I have the same result

Ciao.

Giuseppe

0 Karma

jroedel
Path Finder

I tried, but still no luck

Screenshot 2024-10-01 at 11.46.03.png

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...