I resolved this by creating the below custom role and assigning it to user
Note that the operation and db may change for each case
use admin
db.createRole(
{
role: “customRoleConfig”,
privileges: [
{
actions: [ “collStats”, “indexStats” ],
resource: { db: “config”, collection: “system.indexBuilds” }
},
{
actions: [ “collStats”, “indexStats” ],
resource: { db: “local”, collection: “replset.election” }
},
{
actions: [ “collStats”, “indexStats” ],
resource: { db: “local”, collection: “replset.initialSyncId” }
},
{
actions: [ “collStats”, “indexStats” ],
resource: { db: “local”, collection: “replset.minvalid” }
},
{
actions: [ “collStats”, “indexStats” ],
resource: { db: “local”, collection: “replset.oplogTruncateAfterPoint” }
}],
roles: })
db.grantRolesToUser( “mongodb_exporter”, [ {role: “customRoleConfig”, db: “admin” }])