Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to collect data from MongoDB Arbiter with enabled authentication #6684

Closed
pnedkov opened this issue Nov 20, 2019 · 1 comment · Fixed by #6742
Closed

Unable to collect data from MongoDB Arbiter with enabled authentication #6684

pnedkov opened this issue Nov 20, 2019 · 1 comment · Fixed by #6742
Labels
area/mongodb bug unexpected problem or unintended behavior
Milestone

Comments

@pnedkov
Copy link

pnedkov commented Nov 20, 2019

In the past I had similar issue: #4163. I decided to file a new one since the versions are different and I provided more relevant and detailed information here.

Relevant telegraf.conf:

System info:

CentOS 7.7
Telegraf 1.12.6
MongoDB 3.2.22
InfluxDB 1.7.9

Steps to reproduce:

  1. Setup three MongoDB nodes in a replica set - Primary, Secondary, Arbiter
replSet=rs0
auth=true
keyFile=/var/lib/mongo-keyfile
  1. Create user in the MongoDB Primary node in the "admin" database
db.createUser( { user: "adm", pwd: "password", roles: [ { role: "root", db: "admin" } ] } )
  1. Setup InfluxDB
    /etc/influxdb/influxdb.conf:
[[udp]]
  enabled = true
  bind-address = ":4444"
  database = "testdb"
  1. Setup Telegraf on all three MongoDB nodes - Primary, Secondary and Arbiter
    /etc/telegraf/telegraf.conf:
urls = ["udp://<influxdb_ip>:4444"]
database = "testdb"
  1. On the MongoDB Primary and Secondary nodes create /etc/telegraf/telegraf.d/mongod.conf with the following content:
[[inputs.procstat]]
    exe = "mongod"

[[inputs.mongodb]]
    servers = ["mongodb://adm:password@127.0.0.1:27017"]
    col_stats_dbs = ["testdb"]

Hint: This will work.

  1. On the MongoDB Arbiter node create /etc/telegraf/telegraf.d/mongod.conf with the following content:
[[inputs.procstat]]
    exe = "mongod"

[[inputs.mongodb]]
    servers = ["mongodb://127.0.0.1:27017"]

Hint: This fails.
Note: No username and password since there are no users on the MongoDB Arbiter.

  1. Login to the InfluxDB and check if there are any measurements for all three MongoDB nodes
# influx
Connected to http://localhost:8086 version 1.7.9
InfluxDB shell version: 1.7.9
> 
> use testdb
Using database testdb
>
> show tag values from mongodb with key = "host";

Expected behavior:

Telegraf on the MongoDB Arbiter node should be able to login to the local mongod server, collect information and push it to the InfluxDB. The influxdb query should return all three MongoDB nodes:

show tag values from mongodb with key = "host";

Actual behavior:

After step 6 you will see that influxdb contains measurements only for MongoDB Primary and Secondary nodes. No data is coming from MongoDB Arbiter.

This error is logged in the Telegraf log file on the MongoDB Arbiter node:

[inputs.mongodb] Error in plugin: not authorized on local to execute command { find: "oplog.$main", filter: { ts: { $exists: true } }, sort: { $natural: 1 }, skip: 0, limit: 1, batchSize: 1, singleBatch: true }

Additional info:

Everything works as expected if you follow the exact steps to reproduce but using Telegraf 1.11.5. Something is wrong with Telegraf 1.12.6.

@danielnelson danielnelson added this to the 1.12.7 milestone Nov 22, 2019
@danielnelson danielnelson added area/mongodb bug unexpected problem or unintended behavior labels Nov 22, 2019
@danielnelson danielnelson modified the milestones: 1.12.7, 1.13.0 Dec 3, 2019
@pnedkov
Copy link
Author

pnedkov commented Dec 4, 2019

Confirmed, it works with 1.13.0-rc2. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mongodb bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants