How can you view the IP addresses of active MongoDB Atlas connections?
-
26-01-2021 - |
문제
Some posts show you can use db.currentOp(true) to show active connections, but when I do that I get this error
{
"ok" : 0,
"errmsg" : "Using $all for currentOp is disallowed in this atlas tier",
"code" : 8000,
"codeName" : "AtlasError"
}
Is there another way to view active connections to a MongoDB Atlas Cluster? What tier allows you to use this command?
해결책
If I understand correctly, this is about how to view ip addresses that got connected to your mongoDB Atlas cluster, I would say you can see number of connections established to a cluster by just logging into your Atlas mongoDB cloud dashboard (Atlas login). But if you want details on connections established, then you can download logs for that particular cluster as a file, You can navigate to it as given below, but you might only see this option for paid versions, Technically db.currentOp(true)
should work, but for some reason it didn't, not sure why, maybe unsupported !! (mongoDB-unsupported-commands) :
다른 팁
MongoDB Atlas Free tier, In the Cluster Overview page you should be able to the see the number active connections to the cluster as shown below.
UPDATE
Since Atlas Free Tier doesn't allow to run db.currentOp()
, The one other way is to check the MongoDB log files for active connection IP Address. In the log file look for the latest entry like below
2019-03-28T09:42:49.795-0700 I NETWORK [listener] connection accepted from 192.168.1.1:62408 #1 (1 connection now open)
This will give you the number of active connections and from which are IP address the connection is made. Also, to check the connections is closed or not
2019-03-28T09:51:48.797-0700 I NETWORK [conn7] end connection 192.168.1.1:62408 (0 connections now open)
How can you view the IP addresses of active MongoDB Atlas connections?
As per MongoDB documentation here the IP address has been added in Atlas cluster will appears under the Check the IP Whitelist
section under the Security
tab.
For example in screenshot It has been chosen as IP Whitelist
as Any to Any ( i.e IP address is 0.0.0.0/0). If you shall chose your current IP address in IP Whitelist
then it will show your current Public IP address.
After Edit
Suppose that during the Security IP Whitelist configuration time,I have been added my IP Address through the ADD IP Address button as it's appear on the right top corner of the Cluster window screen such as
After adding my Public IP (37.186.35.171/32)is appears like that
And the status of the connection is shows as ACTIVE status. Even I have logged two times from the Atlas cluster and again login to the cluster as it's always IP Address is appearing as 37.186.35.171/32. Which I have been red highlighted through arrow in the screenshot.