Skip to main content

Hi,

I try to use the mongodb plugin Documentation

I manage to connect to the mongodb and get data if I use a user with admin privilege.

I tried to define a user with just the required rights as given in the documentation:

    listDatabases
    listCollections
    collStats
    serverStatus
    dbStats

I have defined the following role:

admin> db.getRole( "centreonMonitoring", { showPrivileges: true } )
{
_id: 'admin.centreonMonitoring',
role: 'centreonMonitoring',
db: 'admin',
privileges:
{
resource: { db: 'admin', collection: '' },
actions: /
'collStats',
'dbStats',
'listCollections',
'listDatabases',
'serverStatus'
]
},
{
resource: { db: '', collection: '' },
actions: /
'collStats',
'dbStats',
'listCollections',
'listDatabases',
'serverStatus'
]
}
],
roles: ]],
inheritedRoles: ],
inheritedPrivileges: r
{
resource: { db: 'admin', collection: '' },
actions: /
'collStats',
'dbStats',
'listCollections',
'listDatabases',
'serverStatus'
]
},
{
resource: { db: '', collection: '' },
actions: /
'collStats',
'dbStats',
'listCollections',
'listDatabases',
'serverStatus'
]
}
],
isBuiltin: false
}

However I do not get any data for:

  • Connexions
  • Queries
  • Collections statistics

Error message is: UNKNOWN: MongoDB::DatabaseError: not authorized on admin to execute command { serverStatus: 1, $readPreference: { mode: "primaryPreferred" }, $db: "admin" }

But following data is retrieved

  • Database statistics
  • connection times

I suppose I need other privileges for my user but which ones?

The predefined role clusterMonitor is required to have a proper access

I added it to my role and I am now able to get all the data

db.grantRolesToRole(
"centreonMonitoring",
[ "clusterMonitor" ]
)

 


Reply