website logo
Request featuresJoin Our Community
⌘K
KloudMate
Getting Started
Why KloudMate?
Setting Up KloudMate
FAQs (Frequently Asked Questions)
Getting Help
Dashboards
Creating a Dashboard
Managing Dashboards and Panels
Explore
AWS Inventory
Lambda Functions
Logs
Traces
Issues
OpenTelemetry Support in KloudMate
What Is OpenTelemetry?
How Does OpenTelemetry Work?
Sending Data to KloudMate
Installing the OpenTelemetry Collector
Using OpenTelemetry Collector
Using OpenTelemetry SDKs
Service Integration Guides
Alarms & Notifications
Understanding KloudMate Alarms
Setting Up KloudMate Alarms
Writing Expressions for KloudMate Alarms
Setting Up Notifications
Settings
Accounts
Sync Settings
Users & Permissions
Subscription & Billing
Usage Report
Profile & Security
Deleting Your AWS Account from KloudMate
Docs powered by
Archbee
OpenTelemetry Support in Kloud...
...
Service Integration Guides
MongoDB Telemetry Data to Klou...

MongoDB Telemetry Data to KloudMate Using OpenTelemetry Collector

11min

This document provides a guide on how to send MongoDB telemetry data to KloudMate using OpenTelemetry Collector.

In the described setup, the latest MongoDB instance is running on an EC2 server. An exporter is required to export metrics to a monitoring backend. In this process, the metrics will be exported by the MongoDB exporter and the penTelemetry collector will be responsible to send metrics data to KloudMate backend.

Step 1: Prerequisites:

  • MongoDb installed and running on http://127.0.0.1:27017
  • Install OpenTelemetry collector. See Installing and Configuring OpenTelemetry Collector.

Recommendations: Install otelcol-contrib releases.

Step 2: Install and configure MongoDB exporter:

  • Add user and group for exporter
Text
|
$sudo groupadd --system <mongodbuser>
$sudo useradd -s /sbin/nologin --system -g <mongodbuser> <mongodbuser>

  • Download and extract MongoDB Exporter
Text
|
$wget https://github.com/percona/mongodb_exporter/releases/download/v0.39.0/mongodb_exporter-0.39.0.linux-amd64.tar.gz   
 /$tar xvzf mongodb_exporter-<latest>
 $sudo mv mongodb_exporter /usr/local/bin/


  • Enable MongoDB authentication
Text
|
$mongosh
>use admin
>db.createUser({ user: "USER", pwd: "PASSWORD", roles: [{ role: "clusterMonitor", db: "admin" }] })
>exit

  • Create a system file for the MongoDB exporter and run it as a service.
Text
|
$sudo nano /etc/systemd/system/mongodb_exporter.service

[Unit] Description=MongoDB Exporter [Service] User=<mongodbuser> Type=simple Restart=always ExecStart=/usr/local/bin/mongodb_exporter --mongodb.uri=mongodb://USER:PASSWORD@127.0.0.1:27017 --collect-all --compatible-mode [Install] WantedBy=multi-user.target
Text
|
$sudo systemctl daemon-reload
$sudo systemctl start mongodb_exporter.service
$sudo systemctl status mongodb_exporter.service 



Step 3: Test the available metrics.

Text
|
$curl http://localhost:9216/metrics


Step 4: On the OpenTelemetry collector add the MongoDB exporter path on Prometheus receiver and export to KloudMate backend.

Text
|
receivers:
  prometheus:
    config:
      scrape_configs:
      - job_name: 'prod-mongodb'
        scrape_interval: 10s
        static_configs:
          - targets: ['localhost:9216']
exporters:  
  otlphttp:
    endpoint: 'https://otel.kloudmate.com:4318'
    headers:
      Authorization: <xxxxxxxxxxxxxxxxxxx>



Step 5: For logs, OpenTelemetry has a file log receiver that can export logs written on a file to a specific backend. Add the file log receiver and include the path of the file which needs to be exported.

Text
|
receivers:
  filelog:
    include: [ </var/log/mongodb/*.log> ]
    attributes:
      service.name: "prod-mongodb"
exporters:  
  otlphttp:
    endpoint: 'https://otel.kloudmate.dev:4318'
    headers:
      Authorization: <xxxxxxxxxxxxxxxxxxx>


If the collector is unable to send logs after these configurations then this might be the permission issue for the otelcol-contrib. Edit the otelcol-contrib service at /lib/systemd/system/otelcol-contrib.service and change the user and group to root.

Did this page help you?
PREVIOUS
MongoDB Telemetry Data to KloudMate
NEXT
MongoDB Telemetry Data to KloudMate Using Fluentbit
Docs powered by
Archbee
Docs powered by
Archbee