top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to call db.Collection.stats() from MongoDB java driver

+2 votes
470 views

From Mongodb client, we can use db.Collection.stats() to get status of collections, such as:

+ Number of records (count) 
+ Size on disk (storageSize) 
+ Indexes (indexSizes) 
+ Average object size (avgObjSize) 

Now I want to monitor these data from web backend with Mongodb java driver, please let me know how to get them?
I've referred: http://mongodb.github.io/mongo-java-driver/3.0/driver-async/getting-started/quick-tour-admin/ but it's not enough information for me. Any pointer?

posted Jun 25, 2015 by Deepak Dasgupta

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

I want to list the size of the different database and trying the function:

db.stats()

But, my developer team is worried over that this might have a huge impact of the system. Should I be worried?

How does this function detect the statistic information such as the size of the different databases. Or is it a better way to detect the size of the database that I can use, which has little or no performance impact ..

0 votes

My collection is like this, but I want to update a nested object with {"env":"qa"} in my updated collection with java-driver:

{ "_id" : ObjectId("5b052eeff9290437b217b1ed"), "app" : "hike", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}{ "_id" : ObjectId("5b052f36f9290437b217b1ee"), "app" : "viber", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}

+1 vote

Can we connect to MongoDB Server 2.6.12 using Java Driver version 0.11? We have a constraint of upgrading Java Driver version which would require huge change in our client code. We use JDK 8 for compilation of our project. We would like to know whether it is possible to connect to MongoDB Server 2.6.12 or MongoDB Server 3.0 using Java Driver version 0.11 if we only use the limited set of features (not the functionalities that were introduced in Server version 2.6.12 or 3.0).

+3 votes

Here I would like to explain my query a bit more.

I inserted multiple documents within a collection. Few documents have same set of keys and few of them have some extra key:value pairs . For example:
document 1 : key1 : "key1"
document 2: key1 : "key1", key2: "key2"
document 3: key1 : "key1", key2: "key2", key3 : "key3"
document 4: key1 : "key1", key3 : "key3"

Now I want to delete the documents which have key1 and key2.
What will be the command to do so ?

...