logstash-input-mongodb icon indicating copy to clipboard operation
logstash-input-mongodb copied to clipboard

get collection of document

Open JuHwon opened this issue 8 years ago • 2 comments

My collection configuration looks like this: collection => '.*' Is there a way i can find out the collection of which the document is coming from? By looking into the source code i could not find anything like that.

JuHwon avatar May 30 '16 12:05 JuHwon

you can see it in the terminal where logstash is running. it prints something like this along with the document's ID -

D, [2016-09-14T18:15:42.105000 #8420] DEBUG -- : MONGODB | QUERY | namespace=db.Product selector={:_id=>{:$gt=>BSON::ObjectId('57d946573031daf42448ed86')}} flags=[:slave_ok] limit=30 skip=0 project=n il | runtime: 25.0001ms

harshit1810 avatar Sep 14 '16 13:09 harshit1810

I was able to do it by using document_type => "%{[_class]}"

_class will give you the full namespace, and is in the mongo output all of the time from what I could tell.

If you need a subset of the full namespace you can use the grok plugin or the mutate - gsub plugin to get a substring.

It would be nice if it was provided though. The 'generateId' option did not work for me.

thejeff77 avatar Sep 20 '17 22:09 thejeff77