
Mongodb Connection
Monitor MongoDB driver connection-pool events and metrics so you can spot exhaustion and misconfiguration before production outages.
Overview
MongoDB Connection is an agent skill for the Operate phase that explains how to monitor MongoDB driver connection pools via standard lifecycle and check-out events.
Install
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-connectionWhat is this skill?
- Maps standard driver events: pool created/closed, connection churn, check-out started/checked-in/failed
- Treats ConnectionCheckOutFailed and rapid ConnectionCreated as critical alert signals
- Points to the cross-driver Connection Monitoring and Pooling specification
- Guidance for interpreting pool metrics and verifying configuration in production
Adoption & trust: 1.4k installs on skills.sh; 131 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You cannot tell whether MongoDB connection limits, pool sizing, or traffic spikes are causing timeouts and failed operations in production.
Who is it for?
Solo builders shipping APIs or SaaS backends on MongoDB who need a checklist for pool monitoring during incidents or post-deploy verification.
Skip if: Greenfield schema design or query optimization with no running app—use data modeling and indexing skills first.
When should I use this skill?
Users need to verify MongoDB connection pooling configuration is working or troubleshoot connection-related issues in a running application.
What do I get? / Deliverables
You know which driver events and metrics to watch, when to alert on pool exhaustion, and how to tie observations back to configuration changes.
- List of driver events to subscribe to and alert on
- Interpretation of pool health signals and recommended follow-up actions
Recommended Skills
Journey fit
How it compares
Operational driver-event reference for pooling health, not a generic ORM connection-string cheat sheet.
Common Questions / FAQ
Who is mongodb-connection for?
Indie and solo developers operating MongoDB-backed services who already use official drivers and need structured pool monitoring and troubleshooting steps.
When should I use mongodb-connection?
Use it in Operate when you see connection timeouts, rising ConnectionCheckOutFailed events, or after changing maxPoolSize, URI options, or traffic patterns on a live deployment.
Is mongodb-connection safe to install?
It is documentation-style guidance without executing shell or network actions in the skill itself; review the Security Audits panel on this Prism page before installing any skill from the catalog.
SKILL.md
READMESKILL.md - Mongodb Connection
# MongoDB Connection Monitoring Guide This reference provides detailed guidance on monitoring connection pool health, interpreting metrics, and taking action based on what you observe. Consult this when users need to verify their configuration is working or troubleshoot connection-related issues. ## Driver Events All MongoDB drivers implement the [Connection Monitoring and Pooling specification](https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md), which defines standard events for tracking pool lifecycle and connection state: **Pool lifecycle events**: - `ConnectionPoolCreated` / `ConnectionPoolClosed` - Track when pools are initialized or shut down **Connection lifecycle events**: - `ConnectionCreated` / `ConnectionClosed` - Monitor connection churn (rapid creation = pooling issues) **Check-out events**: - `ConnectionCheckOutStarted` - Operation requests a connection - `ConnectionCheckedOut` / `ConnectionCheckedIn` - Track when connections are borrowed/returned - `ConnectionCheckOutFailed` - **Critical alert signal** - indicates pool exhaustion **Tip:** Send `ConnectionCheckOutFailed` events and rapid `ConnectionCreated` events to your monitoring system immediately. Access methods vary by driver. Consult your driver's [documentation](https://www.mongodb.com/docs/drivers/) for how to subscribe to these standard events. --- ### Driver-Level Metrics to Watch #### Connections Created **What it is**: The total number of connections the pool has established since initialization. **Events**: - `ConnectionCreatedEvent` - fired when a new connection object is instantiated. **What to watch for**: Rapid increases (+100 connections/hour in steady state) indicate connection churn due to network issues or misconfiguration. **Healthy pattern**: Gradual increase during application startup as the pool warms up, then relatively stable. You should see increases mainly when: - Application restarts - Pool size is increased - Network disruptions force reconnections **Troubleshooting**: - **Rapid growth**: Indicates connection churn. Check: - `maxIdleTimeMS` is not too aggressive - Network stability - Application not creating new clients repeatedly - Serverless functions caching clients properly --- #### Connections In-Use **What it is**: The number of connections currently borrowed from the pool and serving application requests. **Events**: - `ConnectionCheckedOutEvent` - increment counter (connection borrowed) - `ConnectionCheckedInEvent` - decrement counter (connection returned) **What to watch for**: Consistently high values approaching `maxPoolSize` signal potential pool exhaustion. **Healthy pattern**: Fluctuates with application traffic while maintaining headroom. Should correlate with request volume. **Action thresholds**: - **Sustained >80% of maxPoolSize**: Increase `maxPoolSize` by 20-30% - **Consistently 100%**: Pool is definitely exhausted; immediate action needed - **High percentage with high wait queue times**: Clear sign of undersized pool --- #### Connections Available **What it is**: The number of open but unused connections ready in the pool. **Events**: - `ConnectionCheckedInEvent` - increases available count - `ConnectionCheckedOutEvent` - decreases available count **What to watch for**: Consistently zero means the pool is undersized. **Healthy pattern**: Some available connections (10-20% of `maxPoolSize`) ready to handle sudden traffic spikes without waiting for new connection establishment. **Action thresholds**: - **Always zero during traffic**: Pool is too small; connections are never released - **Very low during normal load**: Consider increasing `maxPoolSize` or `minPoolSize` --- #### Wait Queue Size **What it is**: The number of operations currently waiting for an available connection because the pool is at capacity. **Event**: - `ConnectionCheckoutStartedEvent` - track when threads enter wait queu