fluent-plugin-mongo icon indicating copy to clipboard operation
fluent-plugin-mongo copied to clipboard

connecting to mongo replicaset and using SSL as well

Open UnP1u9 opened this issue 2 years ago • 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:[email protected]/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!

UnP1u9 avatar Mar 07 '22 09:03 UnP1u9

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:[email protected]/yourdb
  replica_set atlas-xxxx-shard-0

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

eindrawan avatar Aug 15 '22 08:08 eindrawan

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

akhilaj avatar Aug 22 '22 09:08 akhilaj

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

eindrawan avatar Aug 22 '22 09:08 eindrawan

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 avatar Aug 24 '22 04:08 akhilaj

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

eindrawan avatar Aug 24 '22 12:08 eindrawan

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

@type mongo_replset

  collection fluentd

  connection_string mongodb+srv://abc:[email protected]/Db

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

akhilaj avatar Aug 25 '22 07:08 akhilaj

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

kush003 avatar Oct 13 '22 16:10 kush003

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

eindrawan avatar Oct 13 '22 16:10 eindrawan