Splunk Search

Date Parsing

simontam
Explorer

Dear all,

I am collecting some application logs as below.

Splunk can parse my log very well if the timestamp shows like below.
[2015-05-0609:04:03:681][26411196]: log content...

But if the hour is "00", it seems that Splunk cann't parse the date. And which it leads me AggregatorMiningProcessor errors.
[2015-05-0600:04:03:681][26411196]: log content...

I have tried to put time_format in props.conf but everything behaved the same.
[mysourcetype]
TIME_PREFIX = [
TIME_FORMAT = %Y-%m-%d%H:%M:%S

Any idea for me? Thanks in advance.

Tags (1)
0 Karma

woodcock
Esteemed Legend

The problem is that there is no punctuation between your day-of-month and hour-of-day so when hour-of-day is 0 (or "00"), Splunk consumes both is as part of day-of-month (e.g. "0600"->"6"->June).

There are 2 options; you can use datetime.xml to do it yourself or you can use resortdate to reformat the timestamp in the raw event to add punctuation and then use the normal stuff you already had (with a tweak):

Option 1 datetime.xml:

<datetime>
<define name="_nospacedate" extract="year, month, day">
<text>[(\d{4})-(\d{2})-(\d{2})</text>
</define>
<define name="_nospacetime" extract="hour, minute, second">
<text>[\d{4}-\d{2}-\d{2}(\d{2}):(\d{2}):(\d{2})</text>
</define>
<timePatterns>
<use name="_nospacetime"/>
</timePatterns>
<datePatterns>
<use name="_nospacedate"/>
</datePatterns>
</datetime>

Option 1 props.conf:

[mySourcetype]
DATETIME_CONFIG = /etc/apps/MyApp/default/datetime.xml

Option 2 transforms.conf:

[resortdate]
REGEX = (\d{4})-(\d{2})-(\d{2})(\d{2}):(\d{2}):(\d{2})
FORMAT = $1-$2-$3 $4:$5:$6
DEST_KEY = _raw 

Option 2 props.conf:

[mySourcetype]
TRANSFORMS-sortdate = resortdate
TIME_PREFIX = [
TIME_FORMAT = %Y-%m-%d %H:%M:%S
0 Karma

jeffland
SplunkTrust
SplunkTrust

Have you tried to look at how things look during the "Add Data" wizard? Maybe the step in which splunk tries to parse the timestamp can show you further details as to why it fails. You should see some kind of warning on events which have "00" as hour, along a hint with what is wrong.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...