fluent/fluent-plugin-mongo

connecting to mongo replicaset and using SSL as well

UnP1u9 opened this issue · 8 comments

Hey Guys,

I am trying to connect to mongo_replset using SRV record but am unable to connect,

using below config.

@type mongo_replset
connection_string mongodb+srv://username:password@mongo-server-srv-example.com/log_db?tls=true&authSource=admin&replicaSet=mongo-rep
ssl true
ssl_ca_cert /tmp/tls

it does not work with this config, I am creating all this using code so don't have names of nodes behind the mongo replica set (hosted on DigitalOcean).

config works when I put node name in host entry like below. but this is not the best way in production.

@type mongo_replset
host mongo-server-node-example.com:27017
replica_set mongo-repl
database db
user user
password "password"
ssl true
ssl_ca_cert /tmp/tls

Please suggest. Thanks!

I have this similar problem yesterday, and its working using this config:
in my case i was trying to connect to mongodb atlas

 @type mongo_replset
  connection_string mongodb+srv://user:pass@cluster.mongodb.net/yourdb
  replica_set atlas-xxxx-shard-0

  ssl true
  ssl_cert /tmp/tls/generated-cert.crt

@eindrawan Hi, Were you able to resolve this, we are also facing similar issue. Please help..

@akhilaj, yes, you must generate a certificate first, then try to follow my config above

Hi @eindrawan thanks for the response, one more question that I have is did you use a Self Signed Certificate (openSSL) or any specific Authority one.

@akhilaj , I just use openSSL to generate self signed certificate, and its working fine

Thanks @eindrawan for the help, it is working for me now -

@type mongo_replset

  collection fluentd

  connection_string mongodb+srv://abc:abc@dev-mongodb-sss-ss.xxxx.mongodb.net/Db

  replica_set atlas-xxxx-shard-0
  
  ssl true
  
  ssl_cert /opt/bitnami/fluentd/conf/generated-cert.crt

Hi @eindrawan,
Can you please help me to understand how can I create generated-cert.crt through yaml deployment file?

@kush003 , sorry I never tried before, but i guess you can search "generate self-signed certificates for Kubernetes"