# MongoDB Integration

Xitoring's seamless integration with MongoDB allows you to efficiently monitor the load and performance of your MongoDB databases. This document outlines the steps to set up monitoring for MongoDB on both Linux and Windows environments.

# Enable MongoDB Integration

## Supported platforms

The following guide is working on **Linux** and **Windows servers** but some details could be quite different based on the OS version.

The following lines will walk you through enabling MongoDB integration on Xitoring based on your OS.

## on Linux Server

Access MongoDB Shell:

```text
mongo
```

Switch to the Admin Database:

```text
use admin
```

Create a new user:

```text
 db.createUser({
  user: "xitogent",
  pwd: "xitogent!",
  roles: [\
    { role: "clusterMonitor", db: "admin" }\
  ]
})
```

This command creates a user named `xitogent` with the password `xitogent!` and grants the `clusterMonitor` role on the admin database.

## On Windows Server

For Windows environments, the process is similar but might involve using the MongoDB shell or a graphical user interface. Follow these general steps:

1. Access MongoDB Shell or GUI: Use the MongoDB shell or MongoDB Compass for a graphical interface.
2. Switch to the Admin Database: In the shell, run `use admin`.
3. Create a New User: Use the appropriate command or interface to create the user as mentioned in the Linux steps.

```text
db.createUser({
  user: "xitogent",
  pwd: "xitogent!",
  roles: [\
    { role: "clusterMonitor", db: "admin" }\
  ]
})
```

## Enable MongoDB integration on Xitogent

The final step is to call the Xitogent CLI and enable the MongoDB Integration:

```text
xitogent integrate
```

Select MongoDB from the list of available integrations, it will prompt you for the hostname, port, and credentials on the created user as mentioned above.

and that's it the MongoDB integration is now enabled and the configuration file is created in the `/etc/xitogent/integrations/mongo_integration.conf`.

# Create Triggers for MongoDB integration

You can create Triggers for MongoDB integration and define incidents for the following parameters:

```text
CPU
Memory
Current Connections
Active Connections
Active Sessions
Insert per second
Query per second
Update per second
Delete per second
Command per second
Getmore per second
```
