Using vRops Opensource Telegraf Agent to monitor Mongo DB

Luciano Gomes
3 min readFeb 23, 2022

vRops is a very flexible and powerfull tool. I was trying to monitor the MongoDB 5.x version using the OOTB agent inside vRops, but accordingly this only MongoDB 4.0.8, 4.0.1, 3.0.15, 3.4.19 are compatible. So what? Do not monitor is not a option, so lets use the Opensource agent ! I am not a smart guy, so I will make your life easier than when you follow blogs from smart guys :).

Pre-Requisites:

vRops 8.6 with application monitoring enabled ( See more here )

Enable OpenSource Agent in the Cloud Proxy ( See more here )

Virtual Server where you have the Database you want to monitor with the Telegraf agent already installed ( See more here )

Follow all steps detailed in the official documentation here

Install JQ (See more here ) * Is very important you install the RPM version ( See here )

To configure the agent you will need a token from vRops, I will make your life easier again, install the extension restclient in your firefox, see here be aware of this warning from Mozilla:

In the DOCs, here you can see how you can get the TOKEN, but see what do you need:

And you will configure your rest client like below:

Now you are good to go, see the example below:

./open_source_telegraf_monitor.sh -v 192.168.10.90 -t 43-e136–48d2-b565-f17e038a19c6::df51ad1a-ffba-4e5e-a274–0186810e60b9 -d /etc/telegraf/telegraf.d/ -c 192.168.1.1 -e /usr/bin/telegraf

The explanation:

open_source_telegraf_monitor.sh -v <vROps_IP> -t <AUTHENTIFICATION_TOKEN> -d <TELEGRAF_CONFIG_DIR> -c <CP_IP> -e <telegraf_bin_path>

Description of arguments:
vROps_IP: vRealize Operations Manager FQDN/IP to perform REST API calls.
AUTHENTIFICATION_TOKEN: To perform REST API calls authentication token can be acquired using /api/auth/token/acquire call. Mandatory parameter.
Example: e5c394b4-f333-4391-8028-2040a8bfda60::0dd43038-10e3-4880-a4fc-49e4eaa00e3f
To get the authentication token, follow the steps in Acquire an Authentication Token.
TELEGRAF_CONFIG_DIR: Telegraf configuration directory.
CP_IP: Mention the cloud proxy FQDN/IP address to post metrics.
telegraf_bin_path - Path of telegraf binary. Example: /usr/bin/telegraf

Now you need to configure MongoDB input plugin:

Edit the file in /etc/telegraf/telegraf.d/cloudproxy-http.conf and add the lines below:

# Read metrics from one or many mongodb servers
[[inputs.mongodb]]
## An array of URLs of the form:
## "mongodb://" [user ":" pass "@"] host [ ":" port]
## For example:
## mongodb://user:auth_key@10.10.3.30:27017,
## mongodb://10.10.3.33:18832,
servers = ["mongodb://127.0.0.1:27017"]

fielddrop = ["member_status", "state", "type"]

##Collects metrics exposed by db.stats
gather_perdb_stats = true

## Optional SSL Config
# ssl_ca = "/etc/telegraf/ca.pem"
# ssl_cert = "/etc/telegraf/cert.pem"
# ssl_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false

Restart the agent systemctl restart telegraf and we are good to go, wait some minutes, 15 minutes and we will start to see the Database Inside vRops:

Next post I will share a Dashboard to make your life even easier. Once you did it, you can monitor a lot of other application, what you need to do is just add the configuration of the App you want to monitor, adding it in the /etc/telegraf/telegraf.d/cloudproxy-http.conf and restart the agent.

systemctl restart telegraf

--

--