Server Monitoring2 min read

    How to Monitor MongoDB Database

    By Dana— Server Monitoring & Linux
    Share

    Overview

    MongoDB is a popular NoSQL document database known for its flexibility and scalability. Xitoring's MongoDB integration lets you monitor database load, query performance, connection states, and resource usage — ensuring your MongoDB instances run smoothly at all times.

    What Can It Monitor?

    • CPU — Database server CPU utilization
    • Memory — RAM consumed by MongoDB processes
    • Current Connections — Total open connections
    • Active Connections — Connections currently executing operations
    • Active Sessions — Currently active database sessions
    • Inserts per Second — Rate of insert operations
    • Queries per Second — Rate of find/query operations
    • Updates per Second — Rate of update operations
    • Deletes per Second — Rate of delete operations
    • Commands per Second — Rate of database commands executed

    Prerequisites

    You need to create a dedicated monitoring user with the clusterMonitor role.

    On Linux

    Access the MongoDB shell:

    mongo
    

    Switch to the admin database and create a monitoring user:

    use admin
    
    db.createUser({
      user: "xitogent",
      pwd: "YOUR_SECURE_PASSWORD",
      roles: [
        { role: "clusterMonitor", db: "admin" }
      ]
    })
    

    On Windows

    Use the MongoDB shell or MongoDB Compass:

    1. Open the MongoDB shell or connect via Compass
    2. Switch to the admin database: use admin
    3. Create the monitoring user with the same command as above

    How to Activate the Integration

    Prefer the panel? You don't need the CLI for this step. In Xitoring, open the server, go to Integrations, choose MongoDB, fill in the same details, and click Enable. See enabling integrations from the Xitoring panel. The CLI steps below still work if you script your setup.

    Run the Xitogent CLI:

    xitogent integrate
    

    Select MongoDB from the list of available integrations. When prompted, provide:

    • Hostname (typically localhost)
    • Port (default: 27017)
    • Username and password for the monitoring user

    The config file is created at /etc/xitogent/integrations/mongo_integration.conf.

    Setting Up Triggers

    Available trigger parameters:

    • CPU / Memory
    • Current Connections / Active Connections
    • Active Sessions
    • Inserts per Second
    • Queries per Second
    • Updates per Second
    • Deletes per Second
    • Commands per Second

    Navigate to Triggers on your server page, select MongoDB, choose a metric, set thresholds, and configure notification channels.

    Tips

    • Always create a dedicated monitoring user with minimal privileges (clusterMonitor role)
    • Monitor Current Connections to detect connection leaks or surges
    • Track Queries per Second to identify traffic spikes
    • Set alerts on CPU and Memory to catch resource exhaustion early
    • Works on both Linux and Windows servers