Skip to content
Last9 named a Gartner Cool Vendor in AI for SRE Observability for 2025! Read more →
Last9

MongoDB Atlas

Monitor MongoDB Atlas clusters with comprehensive metrics, logs, events, and alerts using OpenTelemetry mongodbatlas receiver with Last9

Use OpenTelemetry to instrument your MongoDB Atlas databases and send telemetry data to Last9.

Read the setup guide for more details.

Prerequisites

Before setting up MongoDB Atlas monitoring, ensure you have:

MongoDB Atlas API Access

  1. Create API Keys: Navigate to your MongoDB Atlas Project → Access Manager → API Keys
  2. Generate Public/Private Key Pair: Create an API key with appropriate permissions
  3. Required Permissions:
    • For metrics and logs: Project Read Only role minimum
    • For project events: Project Read Only role minimum
    • For organization events: Organization Member role minimum
    • For access logs: Project Owner or Organization Owner role

Enable Required Features

  1. Database Auditing (optional): Enable in MongoDB Atlas Project Settings if you want to collect audit logs
  2. Monitoring API: Ensure monitoring APIs are accessible for your project
  3. Project Configuration: Note your Project Names and Cluster Names for configuration
  1. Install OpenTelemetry Collector

    sudo apt-get update
    sudo apt-get -y install wget systemctl
    wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.deb
    sudo dpkg -i otelcol-contrib_0.118.0_linux_amd64.deb
  2. Configure OpenTelemetry Collector

    Use the following configuration for collecting MongoDB Atlas metrics:

    receivers:
    mongodbatlas:
    public_key: "${env:MONGODB_ATLAS_PUBLIC_KEY}"
    private_key: "${env:MONGODB_ATLAS_PRIVATE_KEY}"
    granularity: "PT1M"
    collection_interval: 3m
    projects:
    - name: "YOUR_PROJECT_NAME"
    include_clusters: ["YOUR_CLUSTER_NAME"]
    retry_on_failure:
    enabled: true
    initial_interval: 5s
    max_interval: 30s
    max_elapsed_time: 5m
    processors:
    batch:
    timeout: 5s
    send_batch_size: 10000
    send_batch_max_size: 10000
    resourcedetection/system:
    detectors: ["system"]
    system:
    hostname_sources: ["os"]
    resourcedetection/cloud:
    detectors: ["gcp", "ec2", "azure"]
    exporters:
    otlp/last9:
    endpoint: "{{ .Logs.WriteURL }}"
    headers:
    "Authorization": "{{ .Logs.AuthValue }}"
    debug:
    verbosity: detailed
    service:
    pipelines:
    metrics:
    receivers: [mongodbatlas]
    processors: [batch, resourcedetection/system, resourcedetection/cloud]
    exporters: [otlp/last9]
  3. Environment Variables

    Set the following environment variables before starting the collector:

    export MONGODB_ATLAS_PUBLIC_KEY="your_public_key"
    export MONGODB_ATLAS_PRIVATE_KEY="your_private_key"
  4. Start Collector

    otelcol-contrib --config /etc/otelcol-contrib/config.yaml

Configuration Parameters

Required Parameters

  • public_key: MongoDB Atlas API public key
  • private_key: MongoDB Atlas API private key

Optional Parameters

  • base_url: (default: https://cloud.mongodb.com/) MongoDB Atlas base URL
  • granularity: (default: PT1M) Metrics granularity (see MongoDB Atlas documentation)
  • collection_interval: (default: 3m) How often to collect metrics
  • storage: Component ID of storage extension for preventing data duplication

Projects Configuration

  • name: Name of the MongoDB Atlas project
  • include_clusters: List of specific clusters to monitor (optional)
  • exclude_clusters: List of clusters to exclude from monitoring (optional)

Logs Configuration

  • enabled: Enable log collection
  • collect_host_logs: (default: true) Collect MongoDB host logs
  • collect_audit_logs: (default: false) Collect audit logs (requires enabled audit logging)

Events Configuration

  • projects: List of projects to collect events from
  • organizations: List of organization IDs to collect events from
  • poll_interval: (default: 1m) How often to poll for events
  • page_size: (default: 100) Number of events per API request
  • max_pages: (default: 25) Maximum pages to request per poll

Access Logs Configuration

  • enabled: Enable access log collection
  • auth_result: Filter by authentication result (true/false/unspecified)
  • page_size: (default: 20000) Number of access logs per API request
  • max_pages: (default: 10) Maximum pages to request per poll
  • poll_interval: (default: 5m) How often to poll for access logs

Important Notes

  1. API Rate Limits: MongoDB Atlas has API rate limits. The recommended polling interval is 5 minutes for logs and metrics.

  2. Storage Extension: Use a storage extension to prevent data duplication after collector restarts, especially for events, alerts, and access logs.

  3. Permissions: Ensure your API key has the minimum required permissions for the data you want to collect.

  4. Project and Cluster Names: Replace YOUR_PROJECT_NAME, YOUR_CLUSTER_NAME, and YOUR_ORGANIZATION_ID with your actual MongoDB Atlas project names, cluster names, and organization ID.

  5. Audit Logs: Audit logging must be explicitly enabled in your MongoDB Atlas project settings to collect audit logs.

  6. Access Logs: Access log collection requires Project Owner or Organization Owner permissions.

Verification

To verify the setup is working:

  1. Check that the collector service is running
  2. Review the collector logs for any errors
  3. Log into your Last9 account to confirm MongoDB Atlas metrics are being received

Need Help?

If you encounter any issues or have questions: