Insert a record (ISODate) to MongoDB

53 views
Skip to first unread message

莊興旺

unread,
Sep 17, 2015, 10:36:57 PM9/17/15
to Fluentd Google Group

Dear all:


What could I do differently to achieve the target ?

thanks~


data (csv)

Leonardo,2015-09-02 12:36:15:
Michelangelo,2015-09-03 06:23:11:


configure

<source>
  type tail
  tag mongo
  path /home/vagrant/fluentd/data/*
  format csv
  keys user,date
  types user:string, date:string
  pos_file /home/vagrant/fluentd/pos_file/temp.pos  
</source>

<match forward1.**>
...

  type mongo
  host localhost
  port 27017
  database test
  collection foo
</match>



MongoDB Query Document
current

> db.foo.find() 
{ "_id" : ..., "user" : "Leonardo", "date" : "2015-09-02 12:36:15:" , "time" : ISODate("2015-09-17T05:42:15Z")}
{ "_id" : ..., "user" : "Michelangelo", "date" : "2015-09-03 06:23:11:", "time" : ISODate("2015-09-17T05:42:15Z") }

target

> db.foo.find()
{ "_id" : ..., "user" : "Leonardo", "date" : ISODate("2015-09-02T12:36:15Z") , "time" : ISODate("2015-09-17T05:42:15Z")}
{ "_id" : ..., "user" : "Michelangelo", "date" : ISODate("2015-09-03T06:23:11Z"), "time" : ISODate("2015-09-17T05:42:15Z") }


PS:  In fact , there are a lot of  "date"  fields  in my really data (date1, date2, date3...).

Mr. Fiber

unread,
Sep 18, 2015, 9:43:02 AM9/18/15
to Fluentd Google Group
Do you mean you want to convert all time fields into ISOData type in mongodb?


Masahiro

--
You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

莊興旺

unread,
Sep 20, 2015, 7:41:53 PM9/20/15
to Fluentd Google Group
Dear Masahiro:

  Yes, I want to convert all time fields into ISOData type in mongodb.

   thank you ~ 



repeatedly於 2015年9月18日星期五 UTC+8下午9時43分02秒寫道:

Abhi Chaudhari

unread,
Feb 23, 2017, 10:38:41 AM2/23/17
to Fluentd Google Group
I am also having the same requirement , can someone please help to convert fields to ISO date format
Reply all
Reply to author
Forward
0 new messages