OpenSRE uses MongoDB diagnostics to investigate database-related alerts — checking server health, finding slow queries, monitoring replica sets, and analyzing collection statistics.Documentation Index
Fetch the complete documentation index at: https://opensre.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- MongoDB 4.0+ (4.4+ recommended)
- Network access from the OpenSRE environment to your MongoDB instance
- Valid credentials (if authentication is enabled)
Setup
Option 1: Interactive CLI
Option 2: Environment variables
Add to your.env:
| Variable | Default | Description |
|---|---|---|
MONGODB_CONNECTION_STRING | — | Required. MongoDB connection URI |
MONGODB_DATABASE | (empty) | Target database for profiler and collection stats |
MONGODB_AUTH_SOURCE | admin | Authentication database |
MONGODB_TLS | true | Use TLS for the connection |
Option 3: Persistent store
Integrations are automatically persisted to~/.config/opensre/integrations.json:
Connection string formats
TLS configuration
TLS is enabled by default. For custom certificates:Investigation tools
When OpenSRE investigates a MongoDB-related alert, five diagnostic tools are available:Server status
Retrieves version, uptime, connection counts, operation counters, and memory usage. Useful for spotting high connection counts or unusual memory pressure.Current operations
Lists operations running longer than a configurable threshold (default 1 s). Surfaces long-running queries and lock contention.Replica set status
Reports member states, health, heartbeat intervals, and optime lag. Identifies unreachable members or sync delays.Profiler
Reads thesystem.profile collection to surface slow queries, collection scans, and index usage. Requires MONGODB_DATABASE to be configured and profiling enabled on the target database.
Enable profiling with
db.setProfilingLevel(1) (slow queries only) or db.setProfilingLevel(2) (all queries).Collection statistics
Returns document count, storage size, index count, and average object size for a given collection.Verify
Troubleshooting
| Symptom | Fix |
|---|---|
| Connection refused | Verify the host/port, check firewalls, and ensure MongoDB is running. For Atlas, whitelist the OpenSRE IP. |
| Authentication failed | Confirm username/password and authSource. Test with mongosh first. |
| SSL: CERTIFICATE_VERIFY_FAILED | Provide a CA cert via MONGODB_CA_CERT or set MONGODB_TLS_INSECURE=true for dev. |
| Profiling is disabled | Run db.setProfilingLevel(1) on the target database. |
| Server is not part of a replica set | Expected for standalone instances — replica set tools return empty results, other tools still work. |
Security best practices
- Use a read-only MongoDB user for monitoring — avoid admin credentials.
- Always enable TLS in production.
- Store connection strings in
.env, never in code. - Rotate credentials periodically.
Tracer