Logstas-output-mongodb DB creation

Hi Team,

I am trying to have logstash output for MongoDB and I am unsure whether if i can customize the Mongo DB name based upon the input logstash receives. To be be more precise, I am unaware of the logstash capability whether it can create the Mongo Database if the database doesn't exists by default. Let me share my configurations below.

My Current logstash pipeline looks like below.

input {
 http {
        host => "10.118.237.73"
        port => "8080"
        type => "json"
  }
}

filter {
    ruby {
            path => "/etc/logstash/removeKeys.rb"
         {
        date { match => [ "[repository][pushed_at]", "ISO8601" ] target => "[repository][pushed_at]" }
        mutate {
                        lowercase => [ "[repository][name]" ]
        }
}

output {
  stdout { codec => rubydebug { metadata => true } }
  elasticsearch {
    hosts => "10.199.197.5:9200"
    index => "for-%{[repository][name]}-%{[headers][x_github_event]}-%{+YYYY.MM.dd}"
    manage_template => false
  }
}

If i change the above output details to below,

    output {
      stdout { codec => rubydebug { metadata => true } }
      elasticsearch {
        hosts => "ELK:9200"
        index => "for-%{[repository][name]}-%{[headers][x_github_event]}-%{+YYYY.MM.dd}"
        manage_template => false
      }
	 mongodb {
    id => "my_mongodb_plugin_id"
    collection => "xxxx"
    database => "xxxx"
    uri => "mongodb://<USER>:<PASS>@ddddddd.mlab.com:63156/xxxxx"        
    codec => "json"
  }
    }

The database name that is mentioned above - is there a necessity that it should be existing in the mongodb server side? Or logstash has the ability to create Database and the collection by itself?

Please clarify and help me with any suggested documents/guide for me to go through.

Regards
TJ

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.