From 997406ea2eb4d71b91aa6639e697385e132909db Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Wed, 4 Apr 2018 10:35:32 -0700 Subject: [PATCH] Add details about MongoDB permissions --- plugins/inputs/mongodb/README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/mongodb/README.md b/plugins/inputs/mongodb/README.md index 2bbf6ebfa..c4c308f2f 100644 --- a/plugins/inputs/mongodb/README.md +++ b/plugins/inputs/mongodb/README.md @@ -21,10 +21,20 @@ ## Use SSL but skip chain & host verification # insecure_skip_verify = false ``` -This connection uri may be different based on your environment and mongodb -setup. If the user doesn't have the required privilege to execute serverStatus -command the you will get this error on telegraf +#### Permissions: + +If your MongoDB instance has access control enabled you will need to connect +as a user with sufficient rights. + +With MongoDB 3.4 and higher, the `clusterMonitor` role can be used. In +version 3.2 you may also need these additional permissions: +``` +> db.grantRolesToUser("user", [{role: "read", actions: "find", db: "local"}]) +``` + +If the user is missing required privileges you may see an error in the +Telegraf logs similar to: ``` Error in input [mongodb]: not authorized on admin to execute command { serverStatus: 1, recordStats: 0 } ```