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

telegraf v1.12.0 mongodb input plugin executes listCollections even when gather_col_stats=false with clusterMonitor role #6362

Closed
tomklapka opened this issue Sep 6, 2019 · 0 comments · Fixed by #6364
Assignees
Labels
area/mongodb bug unexpected problem or unintended behavior regression something that used to work, but is now broken
Milestone

Comments

@tomklapka
Copy link

Relevant telegraf.conf:

# # Read metrics from one or many MongoDB servers
[[inputs.mongodb]]
    servers = ["mongodb://telegraf:password@127.0.0.1:27017"]
    gather_perdb_stats = true

System info:

https://dl.influxdata.com/telegraf/releases/telegraf-1.12.0-1.x86_64.rpm - NOT OK
https://dl.influxdata.com/telegraf/releases/telegraf-1.11.5-1.x86_64.rpm - OK

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2018.03

Steps to reproduce:

  1. It assumes running mongodb single node server v4.2 with created telegraf user and ClusterMonitor role in admin db.
  2. Install telegraf-1.12.0 with above mongodb input config
  3. Run telegraf and inspect the log file

Expected behavior:

By default the built-in clusterMonitor mongodb role doesn't allow listCollections command. It shouldn't be used when gather_col_stats = false or document the way how to setup correct user roles in the mongodb server.

https://docs.mongodb.com/manual/reference/built-in-roles/#clusterMonitor

Actual behavior:

It works with older versions of telegraf except 1.12.0.

2019-09-06T14:57:40Z E! [inputs.mongodb] Error getting collection names: not authorized on admin to execute command { listCollections: 1, cursor: { batchSize: 0 }, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }
2019-09-06T14:57:40Z E! [inputs.mongodb] Error getting collection names: not authorized on tripmarket-worker to execute command { listCollections: 1, cursor: { batchSize: 0 }, $readPreference: { mode: "secondaryPreferred" }, $db: "tripmarket-worker" }

Additional info:

telegraf user was created as usual using:

db = db.getSiblingDB('admin');
db.createUser({
  user: "telegraf",
  pwd: "{{ mongo_telegraf_pass }}",
  roles: [ { role: "clusterMonitor", db: "admin" } ]
});
@danielnelson danielnelson added area/mongodb bug unexpected problem or unintended behavior regression something that used to work, but is now broken labels Sep 6, 2019
@danielnelson danielnelson self-assigned this Sep 6, 2019
@danielnelson danielnelson added this to the 1.12.1 milestone Sep 6, 2019
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 regression something that used to work, but is now broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants