MongoDB Atlas Cost Monitoring with Datadog: Track Spend, Detect Anomalies, and Optimize Before the Bill Arrives
MongoDB Atlas pricing is usage-based: you pay for compute tier, storage, data transfer, backup, and features like Atlas Search or Vector Search. The problem is visibility. Atlas shows your current bill in the Billing console, but it updates infrequently, doesn't correlate cost with workload changes, and won't tell you that Tuesday's schema change triggered a 3x storage increase. Datadog's MongoDB Atlas cost integration changes this — it pulls cost data into the same platform where you track performance, so you can correlate spend with the infrastructure decisions that drove it.
You can't optimize what you can't see in real time. By the time the Atlas invoice arrives, the damage is 30 days old.
Setting Up Atlas Cost Monitoring in Datadog
Datadog's Cloud Cost Management supports MongoDB Atlas as a cost source. The integration pulls billing and usage data from the Atlas Administration API and maps it to Datadog's cost management framework — giving you cost breakdowns by project, cluster, and cost category.
Prerequisites
- An active Datadog account with Cloud Cost Management enabled (requires Pro or Enterprise plan).
- A MongoDB Atlas Organization API key with Organization Billing Viewer or Organization Read Only role.
- The Datadog MongoDB Atlas integration already configured (as described in the Atlas monitoring setup).
Configuration
- In Datadog, navigate to Infrastructure > Cloud Costs.
- Click Configure and select MongoDB Atlas as a cost source.
- Enter your Atlas Organization ID, API Public Key, and API Private Key.
- Datadog begins pulling cost data. Historical data for the current billing period appears within 24 hours.
- Costs are broken down by project, cluster, and line item (compute, storage, data transfer, backup, etc.).
What Cost Data You Get
Once connected, Datadog surfaces Atlas costs in multiple views, all correlatable with your performance metrics.
| Data Point | Granularity | What It Shows |
|---|---|---|
| Total Atlas spend | Daily / monthly | Overall cost trend across all projects and clusters |
| Cost by project | Per Atlas project | Which team or service is driving spend |
| Cost by cluster | Per cluster | Individual cluster costs — identify the most expensive clusters |
| Cost by category | Compute / storage / data transfer / backup / serverless | Which cost component is growing fastest |
| Cost per GB (storage) | Per cluster | Storage cost efficiency — are you paying for unused provisioned storage? |
| Data transfer costs | Per cluster / region | Cross-region and internet egress — often the hidden cost driver |
Building a Cost Dashboard
Create a dedicated Atlas Cost dashboard in Datadog with these panels. The goal is to answer 'what changed and why' when costs spike.
- Total daily spend — Timeseries of Atlas daily cost. The baseline for everything else. If this line trends up, the other panels explain why.
- Cost by cluster — Stacked bar chart showing per-cluster daily cost. Quickly identifies which cluster is responsible for a spend increase.
- Cost by category — Pie chart or stacked area of compute vs storage vs data transfer vs backup. Shows your cost mix. If data transfer is 40% of total, that's the optimization target.
- Cost vs throughput — Overlay Atlas daily cost with total ops/sec. Cost growing faster than throughput means decreasing efficiency.
- Cost per million operations — Computed metric: daily cost / daily operations. This is your unit economics metric. It should trend down over time as you optimize.
- Storage growth rate — Timeseries of storage_size with a trend line. Predicts when you'll hit the next storage tier or need a capacity increase.
The most valuable panel on your cost dashboard is 'cost per million operations.' If this number is going up, you're paying more to do the same work. That's where optimization starts.
Cost Anomaly Detection
Datadog's anomaly detection works on cost metrics just like performance metrics. Enable anomaly monitors on your Atlas daily spend to get alerted when costs deviate from the expected pattern.
- Set up an anomaly monitor on total Atlas daily cost — Datadog learns the baseline spending pattern and alerts when costs exceed the expected range by a configurable threshold (e.g., 20% above forecast).
- Set up a change monitor on data transfer costs — Alert when data transfer cost increases by more than 30% week-over-week. Data transfer spikes often indicate a new cross-region query pattern or a missing VPC peering configuration.
- Set up a threshold monitor on storage growth rate — Alert when daily storage growth exceeds a fixed value (e.g., > 5GB/day). Runaway storage growth usually means an unindexed write pattern or a missing TTL on time-series data.
Correlating Cost with Performance Decisions
The real value of Datadog for Atlas cost management is correlation. You can answer questions that the Atlas billing console alone can't.
| Question | How to Answer in Datadog |
|---|---|
| Why did cost spike on Tuesday? | Overlay cost timeseries with deployment events (from CI/CD) and ops counters. Did a new feature increase write volume? |
| Is auto-scaling costing us more than fixed tier? | Compare daily compute cost against daily peak ops/sec. If peaks are brief, auto-scaling may cost more than a fixed tier that handles the peak. |
| Which queries are most expensive? | Combine DBM slow query data with cost-per-operation calculations. The query running 1M times/day with a COLLSCAN is your most expensive query. |
| Are we over-provisioned? | Compare average resource utilization (CPU, memory, IOPS) with provisioned capacity. Below 40% average utilization means you're overpaying. |
| Is data transfer worth the spend? | Compare data transfer cost with the latency improvement from multi-region replicas. If EU latency improved by 50ms but transfer costs $500/month, is it worth it? |
Optimization Actions from Cost Data
Once you have visibility, here are the actions that typically save 20-40% on Atlas costs.
- Right-size the tier — If average CPU utilization is below 40%, drop one tier. Datadog's utilization data gives you the confidence to downsize.
- Switch to annual commits — If your Datadog cost dashboard shows stable month-over-month spend (< 10% variance), move from pay-as-you-go to annual pricing for 20-30% savings.
- Add projections to expensive queries — Use DBM to find the top 10 queries by execution count. Check if they return full documents when they only need a few fields. Adding projections reduces data transfer and read units.
- Enable compression — If data transfer is a significant cost component, enable wire protocol compression (zstd) in your driver connection string.
- Review multi-region necessity — If a remote region's replica costs $200/month in data transfer but serves < 5% of traffic, consider removing it and serving from the primary region.
- Set TTL indexes on time-series data — If storage is growing linearly, check for collections without TTL that should have one. Logs, events, and telemetry data older than 30-90 days rarely needs to be in Atlas.
Cost optimization isn't a one-time project. It's a monthly review of your Datadog cost dashboard. Fifteen minutes each month saves hundreds or thousands in annual Atlas spend.