logstach 8.6.2輸出到mongo 6

苦逼yw發表於2024-07-04

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

相關文章