When trying to set up the mongodb.replstatus metricset on my replica set (MongoDB v3.6), I am given the error:
Error fetching data for metricset mongodb.replstatus: error getting replication info: could not get last operation timestamp in oplog: could not get cursor on collection 'oplog.rs': (OperationFailed) Executor error during find command :: caused by :: errormsg: "Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit."
My oplog collection totals 16GB.
The error seems to happen when the the module attempts to sort the oplog in reverse natural order and get the first result.
From a quick look at the module's source code, the module appears to be executing the query db["oplog.rs"].find({}).sort({ "-$natural": 1 })
to get the last entry in the oplog. Executing this query through the Mongo shell throws the same out of RAM error.
Executing the query db["oplog.rs"].find({}).sort({ "$natural": -1 })
appears to provide the same ordering of results, and does not throw the same error.