phutchins / logstash-input-mongodb

MongoDB input plugin for Logstash
Other
187 stars 104 forks source link

Handle boolean fields #85

Open lorecoro opened 6 years ago

lorecoro commented 6 years ago

At the moment boolean fields in mongo are discarded and don't reach the filter phase.

lorecoro commented 6 years ago

Solution:

diff --git a/lib/logstash/inputs/mongodb.rb b/lib/logstash/inputs/mongodb.rb
index 16b85ab..a1b021d 100644
--- a/lib/logstash/inputs/mongodb.rb
+++ b/lib/logstash/inputs/mongodb.rb
@@ -302,6 +302,8 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
                   else
                     event.set(k.to_s, v)
                   end
+                elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
+                  event.set(k.to_s,v.to_s)
                 else
                   if k.to_s  == "_id" || k.to_s == "tags"
                     event.set(k.to_s, v.to_s )