Skip to content

Commit

Permalink
doc: explain directly connecting to mongo node
Browse files Browse the repository at this point in the history
By default, the mongo-driver library will attempt to use the primary
node of a cluster. For monitoring with Telegraf, users may specify a
secondary node that they want to monitor. In these cases, the user will
need to specify a direct connection to that node.

The library has a number of options for how it connects, which include
primary, primary preferred, secondary, secondary preferred, and closest.
None of these are options to ensure that the specified node is used.

fixes: #11275
fixes: #9555
  • Loading branch information
powersj committed Jun 16, 2022
1 parent 05285a1 commit 6c308e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/inputs/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ All MongoDB server versions from 2.6 and higher are supported.
## For example:
## mongodb://user:auth_key@10.10.3.30:27017,
## mongodb://10.10.3.33:18832,
##
## If connecting to a cluster, users must include the "?connect=direct" in
## the URL to ensure that the connection goes directly to the specified node
## and not have all connections passed to the master node.
servers = ["mongodb://127.0.0.1:27017/?connect=direct"]

## When true, collect cluster status.
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/mongodb/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
## For example:
## mongodb://user:auth_key@10.10.3.30:27017,
## mongodb://10.10.3.33:18832,
##
## If connecting to a cluster, users must include the "?connect=direct" in
## the URL to ensure that the connection goes directly to the specified node
## and not have all connections passed to the master node.
servers = ["mongodb://127.0.0.1:27017/?connect=direct"]

## When true, collect cluster status.
Expand Down

0 comments on commit 6c308e2

Please sign in to comment.