# Piping data from Mongostat to Elasticsearch with Logstash ## Requirements - [Logstash 1.5.x](https://download.elastic.co/logstash/logstash/logstash-1.5.6.tar.gz) - If you want to run Logstash 2.x, see the section titled Logstash 2.x below - Mongostat 2.8+ (for support of the `--json` flag) ## Preparation 1. Copy all of the files from this gist into your Logstash directory. Put `logstash.conf` and `es-template-mongostat.json` in `$LOGSTASH_DIR/conf/`. 2. Edit the connection information in `conf/logstash.conf` for your Elasticsearch output 1. If you change the index name, you'll also need to update the template name in `es-template-mongostat.json`. ## Run ``` bash $ mongostat --json -h localhost --port 27017 -u bob -ppassword --authenticationDatabase admin --discover | python mongostat-filter.py | bin/logstash -f conf/logstash.conf ``` ## Logstash 2.x All of these configs should work fine on Logstash 2.x as well, with the exception of two things: 1. The `logstash-filter-bytes2human` plugin [has not yet been updated](https://github.com/robin13/logstash-filter-bytes2human/pull/1) for Logstash 2.x support. You'll need to manually install a patched version of this plugin if you wish to run 2.x. 2. The syntax for the `logstash-output-elasticsearch` plugin has changed 1. `host` is now `hosts` 2. The `protocol` option has been removed in favor of a separate plugin, `logstash-output-elasticsearch_java`, for communicating over protocols other than HTTP.