Getting Data In

How to convert the MongoDB ISO date to Normal date format in HUnk

rkanumula
Path Finder

Hi,
Can you please share How to convert mongodb ISO date into Normal date format in Hunk . I am getting the date format as "1426185748" but i want the output format as "YYYY-MM-DD"

Thanks in advance

rdagan_splunk
Splunk Employee
Splunk Employee

In my case I added the format = date to the indexes.conf file under /hunk/etc/apps/search/local
That flag will extract ISODate and you should be able to see a JSON format and _timestamp field in the Hunk UI
For example,
[mongodb_movie_rating]
vix.mongodb.collection = movieratings
vix.mongodb.db = raanan
vix.mongodb.field.time = ts
vix.mongodb.field.time.format = date
vix.provider = local-mongodb

After the extraction you can also add more flags in the props.conf. For example, in my case I also have
[movieratings]
MAX_DAYS_AGO = 123456789
TIME_FORMAT = %s
TIME_PREFIX = _timestamp" :

0 Karma

rdagan_splunk
Splunk Employee
Splunk Employee

Can you share your indexes.conf file that includes all the configurations?
There is no props.conf out of the box. You will need to create it.

Look for an example props.conf In this thread
http://answers.splunk.com/answers/225427/how-to-get-hunk-to-parse-the-date-properly-in-my-s.html

In my example, ts is the field + date is the format:
db.movieratings.find()
{ "_id" : ObjectId("5388e41c12569b70c376e9fb"), "userid" : 1, "movieid" : 122, "ts" : ISODate("1996-08-02T11:24:06Z"), "rating" : 5 }
{ "_id" : ObjectId("5388e41c12569b70c376e9fc"), "userid" : 1, "movieid" : 185, "ts" : ISODate("1996-08-02T10:58:45Z"), "rating" : 5 }

0 Karma

rkanumula
Path Finder

Hi rdagan_splunk,

Thanks for giving me the reply

i given all the settings in the MongoDB Virtual index but still i am facing the same and also i have searched the prop.conf file contains Mongo DB Collection name but i didn't find the prop.conf file. Can u please share me the Path of that prop.conf (which contains the Mongo DB collection information)

Thanks in Advance

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 ...