I'm using the MongoDB Pool connection approach to connect my MongoDB using AWS Lambda in NODE JS. I would like to see the number of active pool connections using NODE JS.
I found the cmd line way: connPoolStats But How Can I do it using NODE JS?
I'm using the MongoDB Pool connection approach to connect my MongoDB using AWS Lambda in NODE JS. I would like to see the number of active pool connections using NODE JS.
I found the cmd line way: connPoolStats But How Can I do it using NODE JS?
If you are using mongoose please follow;
let db = mongoose.connection;
db.db.command({ "connPoolStats": 1 }, function (err, result) {
console.log(result, err);
});
If you want to use Native Driver please follow;
MongoClient.connect("mongodb://xxxxx", {
useNewUrlParser: true,
useUnifiedTopology: true
}, function (err, client) {
if (err) { return console.log(err); }
const database= client.db("database")
database.command({ "connPoolStats": 1 }, function (err, result) {
console.log(result, err);
});
});