Advanced MongoDB performance monitoring agent - Query optimization, aggregation pipeline analysis, index usage tracking, connection pool monitoring, and real-time database performance metrics.
npm install @stacksleuth/mongodb-agentStackSleuth MongoDB Agent




Advanced MongoDB performance monitoring agent - Query optimization, aggregation pipeline analysis, index usage tracking, connection pool monitoring, and real-time database performance metrics.
- 🍃 Query Performance Monitoring: MongoDB query optimization insights
- 🔍 Aggregation Pipeline Analysis: Complex aggregation performance
- 📊 Index Usage Tracking: Index efficiency and optimization
- 🔗 Connection Pool Monitoring: Database connection optimization
- 💾 Memory Usage Analysis: MongoDB memory usage tracking
- 🔄 Real-time Metrics: Live database performance monitoring
- ⚡ Multiple Driver Support: Native MongoDB driver and Mongoose
- 📈 Collection-level Stats: Per-collection performance insights
``bashnpm
npm install @stacksleuth/mongodb-agent
`bash
yarn add @stacksleuth/mongodb-agent
``bash
pnpm add @stacksleuth/mongodb-agent
`🏁 Quick Start
`typescript
import { MongoClient } from 'mongodb';
import { MongoDBAgent } from '@stacksleuth/mongodb-agent';// Initialize MongoDB agent
const agent = new MongoDBAgent({
enabled: true,
monitorQueries: true,
trackIndexUsage: true,
slowQueryThreshold: 100 // ms
});
// Connect to MongoDB
const client = new MongoClient('mongodb://localhost:27017');
await client.connect();
// Instrument MongoDB client
agent.instrumentClient(client);
// Start monitoring
agent.startMonitoring();
// Your MongoDB operations are now monitored
const db = client.db('myapp');
const users = await db.collection('users').find({ active: true }).toArray();
`
🛠️ Troubleshooting
$3
Agent Not Starting
`typescript
// Enable debug mode
const agent = new MongodbAgent({
enabled: true,
debug: true
});
`High Memory Usage
`typescript
// Optimize memory usage
const agent = new MongodbAgent({
bufferSize: 500,
flushInterval: 5000,
sampleRate: 0.01
});
`Missing Metrics
- Check that the agent is enabled
- Verify your API key and project ID
- Ensure sampling rate allows data through
- Check network connectivity to StackSleuth API
$3
`bash
DEBUG=stacksleuth:* node your-app.js
``- Official Documentation
- API Reference
- Examples Repository
We welcome contributions! Please see our Contributing Guide for details.
MIT License - see the LICENSE file for details.
---
Website •
Documentation •
NPM Registry •
GitHub
Made with ⚡ by StackSleuth