How to configure and integrate mongodb with telegraf on ubuntu 18.04 LTS - TechBeginner

Welcome to, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to configure and integrate mongodb with telegraf on ubuntu 18.04 LTS

Share This

In this post, We will configure and integrate mongodb monitoring metrics with Telegraf on ubuntu 18.04 LTS

I believe you have already installed and configure prometheus ,Telegraf and MongoDB on your machine if not so then go through the given url to setup prometheus with telegraf on your machine.

MongoDB is an open source NoSQL, cross-stage archive arranged information base. This combination introduces and arranges Telegraf to send mongoDB measurements into Wavefront. Telegraf is a light-weight worker measure equipped for gathering, handling, totaling, and sending measurements to a Wavefront intermediary.

Notwithstanding setting up the measurements stream, this incorporation additionally introduces a dashboard. Here's a screen shot of a model dashboard with insights gathered from MongoDB.

Step 1: Enable MongoDB Plugin in Telegraf

By default telegraf we have got the telegraf.d directory on /etc/telegraf/telegraf.d in this path, You need to create a mongodb.conf configuration file and add the following mongodb plugin syntax by following the given command.

sudo vim /etc/telegraf/telegraf.d/mongodb.conf

Paste the given code to enable the MongoDB plugin in telegraf.

  ## An array of URLs of the form:
  ##   "mongodb://" [user ":" pass "@"] host [ ":" port]
  ## For example:
  ##   mongodb://user:auth_key@,
  ##   mongodb://,
  servers = ["mongodb://"]

  ## When true, collect cluster status.
  ## Note that the query that counts jumbo chunks triggers a COLLSCAN, which
  ## may have an impact on performance.
  # gather_cluster_status = true

  ## When true, collect per database stats
  # gather_perdb_stats = false

  ## When true, collect per collection stats
  # gather_col_stats = false

  ## List of db where collections stats are collected
  ## If empty, all db are concerned
  # col_stats_dbs = ["local"]

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

Here you can uncomments the other parameter to use the username and password for MongoDB monitoring user as per your requirement, Save and exit from the vim text editor.

Step 2: Restart the Telegraf

You need to restart the Telegraf service to get new changes for MongoDB metric in prometheus, Use the following command for the same.

sudo systemctl restart telegraf


We have successfully integrate MongoDB with Telegraf in our Ubuntu 18.04 server.


No comments:

Post a Comment