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
Get Updates on the Splunk Community!

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

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...