Open rockettomatooo opened 4 years ago
I checked basic conf works on my environment.
<match mongo.*>
@type mongo
connection_string mongodb://127.0.0.1:27017/fluent
collection ${tag}
<buffer>
flush_interval 5s
</buffer>
</match>
So if basic configuration doesn't work on your environment, the problem is something wrong, e.g. network setting, port setting, dns setting or etc.
@repeatedly thanks for your answer. Did you check with a mongo replica set locally?
I basically start my mongodb container with mongod --replSet rs0 --bind_ip 0.0.0.0
and when the container starts the first time, you have to run rs.initiate()
on the mongo shell to initialize the replica set. I only have a master though.
Yes. It worked on my local environment with only primary setting.
rs0:PRIMARY> show dbs;
admin 0.000GB
config 0.000GB
fluent 0.000GB
fluentdrs 0.000GB
local 0.000GB
rs0:PRIMARY> use fluentdrs
switched to db fluentdrs
rs0:PRIMARY> show tables;
mongo.test
rs0:PRIMARY> db.mongo.test.find();
{ "_id" : ObjectId("5fa02365b214b345422626df"), "msg" : "hi for rs", "time" : ISODate("2020-11-02T15:18:55.665Z") }
fluentd conf:
<source>
@type forward
</source>
<match mongo.*>
@type mongo_replset
nodes 127.0.0.1:27017
replica_set rs0
database fluentdrs
collection ${tag}
<inject>
time_key time
</inject>
<buffer>
flush_interval 5s
</buffer>
</match>
I have a similar issue. mongodb is stood up as a container within a swarm, thus my fluentd container in the swarm should recognize it by its container name "mongodb". Which I verified using ping and nslookup (but I had to use "mongodb." with the nslookup.)
But when I set the host to mongodb (i've also tried mongodb.) I keep getting the error message described above. Actual IP address works though. fluentd conf:
<mongo.log>
@type mongo
host mongodb
port 27017
database logs
collection ${tag}
<buffer>
flush_interval 5s
</buffer>
<inject>
time_key time
</inject>
</match>
Facing same issue. @rockettomatooo Did you figure out the issue you were having ?
The solution is to use the same host name that comes in "rs.conf()" or "rs.status()" in fluentd conf. Since I was operating in kubernetes, "rs.initiate()" was taking the pod name as host instead of service name. Changed the hostname following https://www.mongodb.com/docs/manual/tutorial/change-hostnames-in-a-replica-set/#:~:text=To%20change%20the%20hostnames%2C%20edit,Switch%20to%20the%20local%20database.&text=Create%20a%20JavaScript%20variable%20for,to%20match%20your%20replica%20set.
cfg = rs.conf() cfg.members[0].host = "mongodb0.example.net:27017" rs.reconfig(cfg)
Hey guys,
I'm trying to setup a pretty simple fluentd config. I simply want some logs to be sent to my replica set (which only consists of 1 primary which is a mongo:4.0.18 docker img) on my local kubernetes. The mongodb server is available on "mongodb.default:27017".
This is my fluentd config
I'm using this Dockerfile for my fluentd container:
with
setup.sh
beeing:Apparently this doesn't work though. I'm always getting this error:
Things I already tried:
@type mongo
instead. usedconnection_string
instead of the standalone params but everything leads to the same error.This is my first time working with fluentd and the mongo-plugin. Also I don't have any experience with ruby. Any ideas / suggestions are appreciated!