Prometheus: The Class Representative

Naveen Singh
5 min readMay 23, 2020

--

Credits

Everyone knows what class representative/ monitor means, the person who tells everything to the teacher and becomes the favorite student.

Meet Prometheus an application that has the same characteristics but instead of a teacher it tells everything to the user using it. Prometheus is a monitoring tool that keeps an eye on every process and creates a graph for better visuals.

Why a monitoring tool?

Suppose you are a chief manager of a development team that handles a website like Facebook.com having a huge database and huge visitors.

This is the typical architecture, how you handle your website and users.

Suppose some user starts complaining that the website is suddenly loading slower from a few hours. This can cause a problem for you because the user/client never waits for 30 to 40 seconds and you lost your users.

Then you asked your team to find out the error and everyone starts checking their own belonging that is networking guy checks the firewall, switch, and router, database administrator assures database and didn’t find any problem, and so on… Individually everything is checked and no problem occurs but what about the whole system who gonna check the whole?

Here Prometheus comes into play, in a single go it will monitor the whole system and tells where the problem occurs. It can also tell in which line, file, program problem occurs. “बहुत तेज़ हो रहे हो”.

How to install Prometheus?

It can be downloaded from its official website for various operating systems. I used Redhat Linux for the same. The installation process is:

Download and extract the file

it has been downloaded and extracted

Go to the extracted folder:

a green-colored Prometheus file is there

A green-colored Prometheus file is there, it is an executable file and to start Prometheus run this file (Don’t start right now, learn the concept first).

Prometheus starts

Prometheus monitors the target(to whom a user has to monitor) in different ways:

(i) Profiling (ii)Tracer (iii)Logs (iv)Metrics

First, we’ll cover the Metrics.

Metrics — Metrics is more like the mathematical term that is there is a box having rows and columns which contain the value, particular value.

In Prometheus Metrics, it monitors the value occurs (of the target) according to the time interval (by default it is 15 seconds) given. It doesn’t tell what problem occurs or in which file, line. For example, CPU utilization suddenly increases from 10% to 65%, then the metrics record the value that is 10 and 65 but doesn’t tell why it increases.

Monitoring of the target to retrieve the metrics is known as Instrumentation.

There are different type of instrumentation :

(i) Node (ii) Service (iii) Application

When the target is an operating system then it is called node instrumentation. Similarly, when the target is a service like a web server, Jenkins, firewall, etc are called Service instrumentation and when the target is an application like PHP, the Python program is called application instrumentation.

Let’s understand this diagram: Yellow Box has an O.S. on which a program of PHP is running, Blue Box has an O.S. on which Webserver is running, Gray Box has an O.S. Green Box contains Prometheus which acts as a server connected to its own defined database called Time Series Database.

Let’s take an example, we have a Linux operating system and we want to monitor RAM utilization/free RAM. “free -m” is the command to check the details of RAM, and Prometheus needs this command’s output to monitor.

How Prometheus will get the information/data/output?

There should be something who gives the detail to Prometheus means something pushes the data to it. This something is called an exporter program, the program pushes the data.

But Prometheus uses the other way that is “pull and download”. Prometheus prompt goes to the target and downloads the data then stores it in the database. For more description click here. This is how the database looks like

Being a special type of database, it stores time, target name, and the operation value which is to be stored. It stores in “Key: Value” pair like “free_mem_output: 8.028453653e+10” (the format is the same but what I have written here is wrong).

How will Prometheus know who is the target?

To know the target, an exporter program should be installed in that system. Here I’m doing node instrumentation so I’ll need a node exporter then download it

Download it, extract it into the target system, and run the program. But when this program runs you’ll be amazed that this program provides a WebUI where you can see all the data exported and you eventually don’t need Prometheus for this.

So I opened this on browser

Then I clicked on metrics and got all the data of the target operating system. Don’t be scared and think about what is written over there. This is syntax of PromQL(Prometheus query language), the language which is used by Prometheus to retrieve data from its own database. For more click here

Retrieving a particular data from the Web page is known as Web-Scrapping.

Again, why Prometheus?

The WebUI given by the exporter is static that is if behind the scene the value is getting changed it won’t show automatically, the user has to refresh the page and the old data gets updated. In this scenario how you will monitor if the value is getting updated and previous value is erased. That’s why Prometheus!

Prometheus also provides a WebUI on default port number 9090

Here expression means the query (to be discussed). The value of a particular expression is saved and used to create a graph for monitoring.

The next part will be updated soon…

--

--

No responses yet