Getting Data In

Splunk Cloud: Why are event timestamps not being extracted from JSON data, using the event's index time instead?

ampledata
Splunk Employee
Splunk Employee

Per: http://docs.splunk.com/Documentation/Storm/Storm/User/Sourcesandsourcetypes

I've tried sending JSON events to Splunk Cloud using all of the following JSONy sourcetypes, none of which seem to result in an accurate timestamp being extracted from my event (instead Splunk Cloud is using the event indexed time):

json_predefined_timestamp

With field: "timestamp": "2014-11-04T20:45:43.000"

json_auto_timestamp

With fields:

"created": 1415133943

or

 "time": 1415133943

All to no avail...

Tags (2)
0 Karma
1 Solution

ampledata
Splunk Employee
Splunk Employee

Figured it out...

Per: http://answers.splunk.com/answers/180585/json-time-not-always-extracted.html

"timestamp" must be the first field of the JSON.

If you're JSON-ifying a Ruby Hash, this can be accomplished via:

require 'date'
require 'json'

my_hash = {'taco': 'delicious'}

# Convert the EPOCH timestamp to a Splunk JSON-compat 'timestamp':
new_timestamp = DateTime.strptime('1415133943', '%s').strftime('%Y-%m-%dT%H:%M:%S.%3N')

# Merge the 'timestamp' field into the beginning of the Hash:
my_hash = Hash['timestamp',  new_ts].merge!(my_hash)

# print the Hash as a JSON String:
puts JSON(my_hash)

View solution in original post

0 Karma

ampledata
Splunk Employee
Splunk Employee

@martin_mueller: I did that deliberately. Thanks though.

0 Karma

ampledata
Splunk Employee
Splunk Employee

Figured it out...

Per: http://answers.splunk.com/answers/180585/json-time-not-always-extracted.html

"timestamp" must be the first field of the JSON.

If you're JSON-ifying a Ruby Hash, this can be accomplished via:

require 'date'
require 'json'

my_hash = {'taco': 'delicious'}

# Convert the EPOCH timestamp to a Splunk JSON-compat 'timestamp':
new_timestamp = DateTime.strptime('1415133943', '%s').strftime('%Y-%m-%dT%H:%M:%S.%3N')

# Merge the 'timestamp' field into the beginning of the Hash:
my_hash = Hash['timestamp',  new_ts].merge!(my_hash)

# print the Hash as a JSON String:
puts JSON(my_hash)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Not sure if relevant, but you're talking about Splunk Cloud while linking Splunk Storm documentation - those are two very different products.

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...