MongoDB Atlas
Integrating MongoDB Atlas Metrics and Logs to KubeSense
KubeSense brings MongoDB Atlas telemetry into the platform through the OpenTelemetry (OTEL) Collector. Once configured, you can monitor Atlas metrics, capture audit and access logs, and visualize them alongside the rest of your infrastructure in KubeSense.
Prerequisites
Before you begin, ensure you have:
- A MongoDB Atlas project with API access enabled
- An Atlas API key pair with at least the
Project Data Access Read Onlyrole - KubeSense deployed with an OTEL Collector that can reach the MongoDB Atlas endpoints
- Audit logging enabled in Atlas if you plan to collect audit logs
- Access to modify the KubeSense Helm values file
Collecting MongoDB Atlas Metrics
Step 1: Update KubeSense Helm Values File
Add the MongoDB Atlas receiver configuration to your KubeSense Helm values file (within the kubesensor section):
otel-collector:
config:
receivers:
mongodbatlas:
# Authentication
public_key: <mongodb-atlas-public-key>
private_key: <mongodb-atlas-private-key>
# Metrics collection interval
collection_interval: 5m
service:
pipelines:
metrics/mongodbatlas:
receivers:
- mongodbatlas
processors:
- batch
exporters:
- otlphttp/kubesense_metricsNote: Replace the public_key and private_key values with your MongoDB Atlas API credentials. Ensure that the OTEL collector endpoint used by otlphttp/kubesense_metrics is configured in your KubeSense deployment.
Step 2: Apply the Configuration
Upgrade your KubeSense deployment with the updated values file:
helm upgrade kubesense kubesense/kubesense \
-f values.yaml \
--namespace kubesenseCollecting MongoDB Atlas Logs
Step 1: Enable Log Collection in Helm Values
Extend the MongoDB Atlas receiver configuration to enable log ingestion:
otel-collector:
config:
receivers:
mongodbatlas:
public_key: <mongodb-atlas-public-key>
private_key: <mongodb-atlas-private-key>
logs:
enabled: true
projects:
- name: "<Atlas Project Name>"
collect_audit_logs: true
collect_host_logs: true
include_clusters: [Cluster0]
access_logs:
page_size: 2000
max_pages: 10
poll_interval: 5m
service:
pipelines:
logs/mongodbatlas:
receivers:
- mongodbatlas
processors:
- batch
exporters:
- otlphttp/kubesense_logsNote: Update the project name, cluster list, and log settings to match your MongoDB Atlas environment. Ensure audit logging is enabled in Atlas if you plan to collect audit logs.
Step 2: Apply the Configuration
Upgrade KubeSense to apply the changes:
helm upgrade kubesense kubesense/kubesense \
-f values.yaml \
--namespace kubesenseMongoDB Atlas Metrics Collected
KubeSense ingests a wide range of MongoDB Atlas metrics, including:
| Metric Name | Type | Unit | Description |
|---|---|---|---|
| mongodbatlas.db.counts | gauge | number | Total number of databases |
| mongodbatlas.db.size | gauge | bytes | Aggregate database size |
| mongodbatlas.disk.partition.iops.average | gauge | ops/s | Average partition I/O operations per second |
| mongodbatlas.disk.partition.latency.max | gauge | milliseconds | Maximum disk partition latency |
| mongodbatlas.process.cpu.usage.average | gauge | percent | Average MongoDB process CPU usage |
| mongodbatlas.process.connections | sum | number | Current number of client connections |
| mongodbatlas.process.db.operations.rate | gauge | operations/s | Database operation rate |
| mongodbatlas.process.memory.usage | gauge | bytes | MongoDB process memory usage |
| mongodbatlas.system.cpu.normalized.usage.average | gauge | percent | Normalized system CPU usage |
| mongodbatlas.system.network.io.max | gauge | bytes/s | Maximum system network throughput |
For the complete list of metrics, refer to the MongoDB Atlas receiver documentation.
MongoDB Atlas Log Attributes
When logs are ingested, the following attributes are available in KubeSense:
| Name | Path | Type | Description |
|---|---|---|---|
| Project | attributes.project | string | MongoDB Atlas project name |
| Cluster | attributes.cluster | string | Cluster identifier |
| Log Type | attributes.type | string | Log category (audit, access, host, etc.) |
| Timestamp | timestamp | timestamp | Time the event was recorded |
| Severity | severity_text | string | Log severity level |
| Message | body | string | Log message content |
Visualization in KubeSense
Once the pipelines are active, MongoDB Atlas metrics and logs populate the KubeSense dashboards and log explorer, allowing you to:
- Monitor CPU, memory, disk, and network trends across clusters
- Track MongoDB operations, connections, and cache activity
- Analyze audit and access logs for security and compliance
- Build alerts and custom views for Atlas environments
Configuration Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
public_key | string | Yes | MongoDB Atlas API public key |
private_key | string | Yes | MongoDB Atlas API private key |
collection_interval | string | No | Frequency of metric collection (5m default) |
logs.enabled | boolean | No | Enable or disable log ingestion |
logs.projects | array | No | List of projects to collect logs from |
logs.projects[].include_clusters | array | No | Cluster names to include |
access_logs.poll_interval | string | No | Polling interval for access logs |
Troubleshooting
Logs Not Appearing
- Ensure audit logging is enabled in Atlas for the target project
- Verify the API key role includes
Project Data Access Read Only - Confirm the project and cluster names in the configuration match Atlas exactly
- Check OTEL collector logs for MongoDB Atlas API errors
Metrics Missing
- Verify the API key permissions and cluster type (some cluster tiers limit metric availability)
- Ensure the
collection_intervalis set to a supported value - Review OTEL collector logs for connectivity or authentication issues
Best Practices
- Rotate Atlas API keys regularly and store them securely
- Limit API key permissions to the minimum required role
- Configure resource tags in
resource/envto differentiate Atlas environments - Use dedicated pipelines for Atlas data to simplify monitoring and alerting
Conclusion
By integrating MongoDB Atlas telemetry with KubeSense, you gain full visibility into Atlas performance, resource utilization, and security events, all within your centralized observability platform.