logstash-input-mongodb
logstash-input-mongodb copied to clipboard
get collection of document
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.
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
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.