# Logstas-output-mongodb DB creation

**URL:** <https://discuss.elastic.co/t/logstas-output-mongodb-db-creation/252305>\
**Category:** Logstash\
**Created:** [October 16, 2020, 6:36am UTC](https://discuss.elastic.co/t/logstas-output-mongodb-db-creation/252305 "2020-10-16T06:36:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamilarasanbravo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tamilarasanbravo/32/62962_2.png) [@tamilarasanbravo](https://discuss.elastic.co/u/tamilarasanbravo)\
**Post date:** [October 16, 2020, 6:36am UTC](https://discuss.elastic.co/t/logstas-output-mongodb-db-creation/252305/1 "2020-10-16T06:36:14Z")

</div>

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.

```auto
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,

```auto
    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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 13, 2020, 6:36am UTC](https://discuss.elastic.co/t/logstas-output-mongodb-db-creation/252305/2 "2020-11-13T06:36:34Z")

</div>

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