AWS documentdb documentation change
Summary
Added new documentation page for the $currentOp aggregation stage in Amazon DocumentDB, including parameters, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds documentation for a monitoring feature ($currentOp) that allows viewing currently running operations. While monitoring can be part of security best practices, there is no evidence this addresses a specific security vulnerability or incident. The documentation is purely instructional for a database operation monitoring feature.
Diff
diff --git a/documentdb/latest/developerguide/currentOp.md b/documentdb/latest/developerguide/currentOp.md index 8b1378917..eff501053 100644 --- a//documentdb/latest/developerguide/currentOp.md +++ b//documentdb/latest/developerguide/currentOp.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#currentOp "Open PDF") @@ -1,0 +3,114 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $currentOp + +The `$currentOp` aggregation stage returns information about currently running operations in the database. This stage is useful for monitoring active queries and operations in an aggregation pipeline. + +**Parameters** + + * `allUsers` (optional): When set to `true`, returns operations for all users. Default is `false`. + + * `idleConnections` (optional): When set to `true`, includes idle connections. Default is `false`. + + * `idleCursors` (optional): When set to `true`, includes information about idle cursors. Default is `false`. + + * `idleSessions` (optional): When set to `true`, includes information about idle sessions. Default is `true`. + + * `localOps` (optional): When set to `true`, includes local operations. Default is `false`. + + + + +## Example (MongoDB Shell) + +The following example demonstrates using the `$currentOp` aggregation stage to retrieve information about active read operations. + +**Query example** + + + db.aggregate([ + { $currentOp: { allUsers: true, idleConnections: false } }, + { $match: { op: "query" } } + ]) + +**Output** + + + [ + { + "opid": "12345", + "active": true, + "op": "query", + "ns": "test.users", + "secs_running": 2 + } + ] + +## Code examples + +To view a code example for using the `$currentOp` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function example() { + const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'); + const db = client.db('admin'); + + const result = await db.aggregate([ + { $currentOp: { allUsers: true, idleConnections: false } }, + { $match: { op: "query" } } + ]).toArray(); + + console.log(result); + await client.close(); + } + + example(); + +Python + + + + from pymongo import MongoClient + + def example(): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client['admin'] + + result = list(db.aggregate([ + { '$currentOp': { 'allUsers': True, 'idleConnections': False } }, + { '$match': { 'op': 'query' } } + ])) + + print(result) + client.close() + + example() + + **Javascript is disabled or is unavailable in your browser.** + +To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions. + +[Document Conventions](/general/latest/gr/docconventions.html) + +$count + +$dateAdd + +Did this page help you? - Yes + +Thanks for letting us know we're doing a good job! + +If you've got a moment, please tell us what we did right so we can do more of it. + +Did this page help you? - No + +Thanks for letting us know this page needs work. We're sorry we let you down. + +If you've got a moment, please tell us how we can make the documentation better.