Reputation: 1553
I have a monitoring script that looks something like this
client = pymongo.MongoClient()
for database in client.database_names():
iterator = client[database].command({"serverStatus":1})["opcounters"].iteritems()
for key, value in iterator:
log(key, data=value, database=database)
This has been giving me the same result for all of my opcounters. Looking at my graphs, I get data like this:
opcounters.command_per_second on test_database: 53.32K
opcounters.command_per_second on log_database: 53.32K
Obviously, "serverStatus" is indicative of the entire server, not just the database.
Is it possible to get opcounters for each database?
Upvotes: 2
Views: 1012
Reputation: 403
There are no per-database opcounts, at least for v2.8.0 or earlier. The op-counter structure that is used in serverStats is a global one. Each new count is recorded without the context of which db or collection was involved.
As an small aside the collStats command does not have op statistics at all so it wont be possible to calculate a database's total ops by aggregation either.
There's an open feature request you can watch/upvote in the MongoDB issue tracker: SERVER-2178: Track stats per db/collection.
Upvotes: 4