Find out user who created database/collection in MongoDB

Viewed 282

I have so many applications on my server who are using mongo db. I want to find out the user name which is being used to create specific db/collection.

I see some application is malfunctioning and keeps on creating dbs dynamically. I want to find out the application through the user which is being used.

What i have done so far is, i found out the connection information from the mongodb logs by grepping that database and then ran this query,

db.currentOp(true).inprog.forEach(function(o){if(o.connectionId == 502925 ) printjson(o)});

And this is the result i am getting,

{
    "host" : "abcd-server:27017",
    "desc" : "conn502925",
    "connectionId" : 502925,
    "client" : "127.0.0.1:39266",
    "clientMetadata" : {
        "driver" : {
            "name" : "mongo-java-driver",
            "version" : "3.6.4"
        },
        "os" : {
            "type" : "Linux",
            "name" : "Linux",
            "architecture" : "amd64",
            "version" : "3.10.0-862.14.4.el7.x86_64"
        },
        "platform" : "Java/AdoptOpenJDK/1.8.0_212-b03"
    },
    "active" : false,
    "currentOpTime" : "2019-07-02T07:31:39.518-0500"
}

Please let me know if there is any way to find out the user.

0 Answers
Related