OpenTelemetry Support
...
Service Integration Guides
MongoDB Telemetry Data to Klou...

MongoDB integration with KloudMate using Opentelemetry

10min

MongoDB is a widely-used NoSQL database designed for scalability and flexibility. It stores data in a JSON-like format (BSON), which allows for dynamic schema design and handling of unstructured data. Known for its high performance in read and write-heavy environments, MongoDB is ideal for applications like real-time analytics, content management, and IoT systems. Available in both open-source and enterprise editions, it offers features like horizontal scaling through sharding and built-in replication for high availability.

This document will guide you on collecting MongoDB server metrics using the OpenTelemetry (otel) MongoDB metrics receiver. This receiver can also help capture metrics on a per-database or per-collection basis from MongoDB instances running on AWS EC2, Azure VMs, or on-premise servers.

Pre-requisites:

  1. The MongoDB server must be running.
  2. This receiver supports MongoDB versions: 4.0+, 5.0, 6.0, 7.0
  3. Install the OpenTelemetry collector on the specific server that requires metric monitoring. See Installing and Configuring OpenTelemetry Collector.
  4. MongoDB recommends setting up a least privilege user (LPU) with a clusterMonitor role in order to collect metrics. Please refer to lpu.sh for an example of how to configure these permissions. To create this please follow the below steps: $mongosh >use admin >db.createUser({ user: "USER", pwd: "PASSWORD", roles: [{ role: "clusterMonitor", db: "admin" }] }) >exit

Step 1: Configure the Receivers to scrape metrics as well as Logs.

  1. To start monitoring MongoDB with Otel Collector, you need to configure the MongoDB receiver:
    • Linux Users: Open the file located at /etc/otelcol-contrib/config.yaml using your preferred text editor.
    • Windows Users: Create a new file called config.yaml in the C:\Program Files\OpenTelemetry Collector folder. You can use Notepad or any text editor to do this.

Add the suitable extensions :

YAML


In this step, two receivers are integrated to retrieve telemetry data from MongoDB.

  • MongoDB Receiver: To retrieve metrics
  • File Log Receiver: To retrieve logs

To get the metrics use only the MongoDB receiver

YAML


Step 2: Set up the processor component to identify resource information from the host and either append or replace the resource values in the telemetry data with this information.

Please choose one of the following configuration options based on your provider (AWS EC2, Azure VM, or on-premises server).

  • Server(Can be on-premise, non-cloud, or cloud)
YAML

  • AWS EC2:

(optional) To retrieve AWS EC2 instance tags along with logs and metrics, users need to associate an IAM role with the EC2 instance that includes the EC2:DescribeTags policy.

YAML

  • Azure Virtual Machines:
YAML


Step 3: Configure the exporter, and extension and save the configuration

Set up the KloudMate Backend on the exporter part of the Open Telemetry configuration file and configure the pipeline.

YAML


Step : To restart and verify the status of the OpenTelemetry (Otel) Collector, follow these steps:

For Linux:

  1. Execute the following commands:
Text


These commands will restart the Otel Collector and display its current status.

For Windows:

  1. Open the Services window:
    • Press Win + R, type services.msc, and press OK.
    • Alternatively, search for "Services" in the Windows Start menu.
  2. In the Services window, locate the "OpenTelemetry Collector" service.
  3. Right-click the service and select "Restart."

Subsequently, monitor the metrics on the KloudMate dashboard and set up an alarm to receive notifications if the potential metrics for a specific application rise.