Getting Data In

timestamp extraction from json

Ekino
Engager

Hi Splunk Gurus

 

Could you someone help me to resolve my Issue with timestamp extraction?

The Issue is that when I want to create a sourcetype with custom timestamp via advanced configuration

where I defined TIME_PREFIX as regular expression ^(?:[^\}\n]*\}){4},\{"\w+":"(?P<timestamp_ex>[^"]+) then timesstamp extraction is not working and I getting  error "failed to parse timestamp. Defaulting to file modtime."

regular expresion I got from splunk field extraction. Why Splunk doesn't accept my regex which was generated by Slunk itself? and tested out via regex101.com where the expression is working.

extract_fields.pngset_source_type.png

Labels (4)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The TIME_PREFIX setting does not tell Splunk how to extract the timestamp field.  It merely tells Splunk where to *find* the timestamp.  The regex should describe the text that comes right before the timestamp.  There's no need for capture groups. 

As is normally the case with the Splunk field extractor, the regex it generates is overly verbose.  It's rarely necessary to describe everything from the beginning of the event until the timestamp - all you need is just enough to find the timestamp.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

Ekino
Engager

Thanks for your answer, it was helpfull

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The TIME_PREFIX setting does not tell Splunk how to extract the timestamp field.  It merely tells Splunk where to *find* the timestamp.  The regex should describe the text that comes right before the timestamp.  There's no need for capture groups. 

As is normally the case with the Splunk field extractor, the regex it generates is overly verbose.  It's rarely necessary to describe everything from the beginning of the event until the timestamp - all you need is just enough to find the timestamp.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...