MongoDB Atlas
Overview¶
OpenSRE uses the Atlas Admin API (not a MongoDB connection string) to inspect cluster health, performance metrics, slow-query recommendations, and operational events when alerts fire.
For direct MongoDB wire-protocol diagnostics, see MongoDB.
Prerequisites¶
- MongoDB Atlas API Public Key
- MongoDB Atlas API Private Key
- Atlas Project ID
- Permissions to view cluster metrics and configuration (Project Read Only or higher)
Setup¶
Option 1: Interactive CLI¶
Enter your Atlas API credentials when prompted.
Option 2: Environment variables¶
MONGODB_ATLAS_PUBLIC_KEY=your_public_key
MONGODB_ATLAS_PRIVATE_KEY=your_private_key
MONGODB_ATLAS_PROJECT_ID=your_project_id
MONGODB_ATLAS_BASE_URL=https://cloud.mongodb.com/api/atlas/v2
| Variable | Default | Description |
|---|---|---|
MONGODB_ATLAS_PUBLIC_KEY |
— | Required. Atlas API public key |
MONGODB_ATLAS_PRIVATE_KEY |
— | Required. Atlas API private key |
MONGODB_ATLAS_PROJECT_ID |
— | Required. Atlas project identifier |
MONGODB_ATLAS_BASE_URL |
https://cloud.mongodb.com/api/atlas/v2 |
Atlas Admin API base URL |
Option 3: Persistent store¶
{
"version": 1,
"integrations": [
{
"id": "mongodb-atlas-prod",
"service": "mongodb_atlas",
"status": "active",
"credentials": {
"public_key": "your_public_key",
"private_key": "your_private_key",
"project_id": "your_project_id"
}
}
]
}
Credentials¶
- Log in to MongoDB Atlas
- Navigate to Access Manager → API Keys
- Create a Project API Key
- Copy the Public Key and Private Key
- Copy the Project ID from Atlas project settings
Info
This integration uses the Atlas Admin API, not a MongoDB connection string. Create a Project API key with read access to cluster metrics and alerts.
Tools¶
| Tool | What it does |
|---|---|
get_mongodb_atlas_clusters |
Clusters in the project — state, version, size, topology |
get_mongodb_atlas_cluster_metrics |
CPU, disk I/O, connections, opcounters |
get_mongodb_atlas_alerts |
Open Atlas alerts |
get_mongodb_atlas_cluster_events |
Recent project events (scaling, backups, maintenance) |
get_mongodb_atlas_performance_advisor |
Slow-query / missing-index recommendations |
Verify¶
Expected output:
Troubleshooting¶
| Symptom | Fix |
|---|---|
| 401 Unauthorized | Regenerate the API key pair. Confirm public and private keys are copied correctly. |
| 403 Forbidden | Grant the API key Project Read Only (or higher) for the target project. |
| Invalid project ID | Copy the Project ID from Atlas project settings — not the cluster name or connection string. |
| Verify passes but tools fail | Confirm MONGODB_ATLAS_PROJECT_ID matches the project that owns the clusters under investigation. |
Security¶
- Create a dedicated Atlas API key for OpenSRE with the minimum project role required.
- Rotate API keys periodically and revoke unused keys.
- Never commit API keys to source control — use
.envor the integration store.
Markdown source: View on AtomGit·Content from the open-source project op/opensre