Kubesense

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:

  1. A MongoDB Atlas project with API access enabled
  2. An Atlas API key pair with at least the Project Data Access Read Only role
  3. KubeSense deployed with an OTEL Collector that can reach the MongoDB Atlas endpoints
  4. Audit logging enabled in Atlas if you plan to collect audit logs
  5. 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_metrics

Note: 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 kubesense

Collecting 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_logs

Note: 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 kubesense

MongoDB Atlas Metrics Collected

KubeSense ingests a wide range of MongoDB Atlas metrics, including:

Metric NameTypeUnitDescription
mongodbatlas.db.countsgaugenumberTotal number of databases
mongodbatlas.db.sizegaugebytesAggregate database size
mongodbatlas.disk.partition.iops.averagegaugeops/sAverage partition I/O operations per second
mongodbatlas.disk.partition.latency.maxgaugemillisecondsMaximum disk partition latency
mongodbatlas.process.cpu.usage.averagegaugepercentAverage MongoDB process CPU usage
mongodbatlas.process.connectionssumnumberCurrent number of client connections
mongodbatlas.process.db.operations.rategaugeoperations/sDatabase operation rate
mongodbatlas.process.memory.usagegaugebytesMongoDB process memory usage
mongodbatlas.system.cpu.normalized.usage.averagegaugepercentNormalized system CPU usage
mongodbatlas.system.network.io.maxgaugebytes/sMaximum 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:

NamePathTypeDescription
Projectattributes.projectstringMongoDB Atlas project name
Clusterattributes.clusterstringCluster identifier
Log Typeattributes.typestringLog category (audit, access, host, etc.)
TimestamptimestamptimestampTime the event was recorded
Severityseverity_textstringLog severity level
MessagebodystringLog 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

ParameterTypeRequiredDescription
public_keystringYesMongoDB Atlas API public key
private_keystringYesMongoDB Atlas API private key
collection_intervalstringNoFrequency of metric collection (5m default)
logs.enabledbooleanNoEnable or disable log ingestion
logs.projectsarrayNoList of projects to collect logs from
logs.projects[].include_clustersarrayNoCluster names to include
access_logs.poll_intervalstringNoPolling 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_interval is 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/env to 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.