iam able to run mongotop
mongostat
only on user that has admin roles. For example i have assigned below roles to the user fred. iam able to run the mongotop
only with user credentials having admin role as shown below.
mongotop --host testdbr1.insuredmine.info --port 12017 -u fred -p fred1 --authenticationDatabase "admin"
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "dbAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "readWriteAnyDatabase",
"db" : "admin"
},
{
"role" : "clusterAdmin",
"db" : "admin"
}
when i use an usercredentials with below role, i get below error
roles: [ { role: "readWrite", db: "dbz" }]
i checked the docs to see if there are any roles i could add to this user to make this command work using this userid, but iam not able to find it in docs https://docs.mongodb.com/manual/reference/program/mongotop/
Failed: (Unauthorized) not authorized on admin to execute command { serverStatus: 1, recordStats: 0, lsid: { id: UUID("cf3fe918-2abf-44c9-b67d-1c7916f84f7f") }, $clusterTime: { clusterTime: Timestamp(1590182369, 3), signature: { hash: BinData(0, 30748E38362C79FB87FB2FA102DC33259F87300E), keyId: 6823102724234543106 } }, $db: "admin", $readPreference: { mode: "primaryPreferred" } }
why i need this?
when i run mongotop
with my admin credential i see output of all databases present in the mongodbinstance. i have multiple database in my replicaset, i dont want to see the output of mongotop
from all the collections in those databases. i want to see only the output of collections running in one specific database