MongoDB
Connect your MongoDB databases to enable Tony (Database Engineer) to analyze queries, optimize performance, and monitor database health.Supported Platforms
| Platform | Support |
|---|---|
| Self-hosted MongoDB | 4.x, 5.x, 6.x, 7.x |
| MongoDB Atlas | All versions |
Setup
Select your MongoDB platform for specific connection instructions:- Self-hosted MongoDB
- MongoDB Atlas
Connect as Admin
Connect to your MongoDB instance using the Mongo shell (
mongosh) with administrative privileges.Replace <admin-user>, <admin-password>, and <your-host> with your credentials. The /admin database is required.Create Read-Only User
Create a dedicated user for CloudThinker using standard MongoDB built-in roles:The
clusterMonitor role is recommended for performance metrics analysis.Configure Network Access
Ensure CloudThinker can reach your database:
- Add CloudThinker IPs to your firewall or security group.
- Ensure MongoDB is bound to an accessible IP address in
mongod.conf.
Add Connection in CloudThinker
Back in the CloudThinker App, navigate to Connections → MongoDB, add your customized Connection String, and finish.Required Permissions
To get the most out of Tony’s analysis, the following standard MongoDB built-in roles are recommended:readAnyDatabase: Required to analyze queries and index usage across your collections.clusterMonitor: Recommended. Provides access toserverStatus,replSetGetStatus, and other diagnostic commands for performance metrics without granting write access.
Agent Capabilities
Once connected, Tony can:| Capability | Description |
|---|---|
| Query Analysis | Identify slow queries, analyze execution plans (explain()) |
| Index Recommendations | Find missing indexes, identify unused indexes |
| Performance Metrics | Monitor connections, memory usage, replication lag |
Example Prompts
Connection Options
| Option | Description | Default |
|---|---|---|
| TLS/SSL | Require TLS for the connection | true |
| Read Preference | Which nodes to route read operations to | primary |
| Connection Timeout | Seconds to wait for connection | 10 |
Troubleshooting
Authentication failed
Authentication failed
- Verify username and password are correct.
- Ensure the user is created on the
admindatabase, or append?authSource=adminto your connection string. - If using Atlas, ensure the user was created with the correct privileges under Database Access.
Connection refused or Timeout
Connection refused or Timeout
- Check if CloudThinker IPs are added to your Atlas Network Access list or your firewall.
- For local MongoDB, ensure
bindIpinmongod.confis not set to only127.0.0.1.
Security Best Practices
- Strong passwords - Use complex, unique passwords for the database user.
- TLS encryption - Always encrypt data in transit (
tls=true). - Network restrictions - Restrict database access to CloudThinker IPs via firewalls or Atlas Network Access.
- Minimal permissions - Never grant write or admin roles to the CloudThinker user.
Related
Tony Agent
Database-focused optimization agent
PostgreSQL Connection
Setup instructions for PostgreSQL databases