logstach 8.6.2输出到mongo4或6版本

 

logstach官网下载:https://www.elastic.co/cn/downloads/past-releases

1、查看logstach有没有自带输出到mongo的插件,到logstach安装目录/bin下

cd /data/logstash-8.6.2/bin/
./logstash-plugin list --verbose

2、没有自带输出到mongo的插件就安装

./logstash-plugin install  logstash-output-mongodb

3、配置logstach输出到mongo。其中密码如果包含特殊字符需要转码,密码转码是我问gpt的

# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.

input {
  kafka {
    bootstrap_servers => ["192.168.1.94:9092"]
    group_id => "som_log"
    topics => ["som_log"]
    codec => json
 }
}

output {
  stdout { codec => rubydebug }
  mongodb {
      database => "som_log"
      collection => "som_log"
      uri => "mongodb://admin:3%3DA%25%7CA%3ERj%29@localhost:27017/admin"
      #codec => line {format => "%{message}"}
  }
}

4、启动logstach

/data/logstash-8.6.2/bin/logstash -f /data/logstash-8.6.2/config/logstash-sample.conf

 

posted @ 2024-07-04 12:02  苦逼yw  阅读(7)  评论(0编辑  收藏  举报