Bobcares

WeSupport

Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Install Prometheus on CentOS 7 for Monitoring Server – How we do it

by | Dec 27, 2020

Need to Install Prometheus on CentOS 7?

 install prometheus on centos 7

At Bobcares, we often get requests from our customers to install Prometheus on CentOS 7 as a part of our Server Management Services.

Today let’s see how our Support Engineers get this done with ease.

Prerequisites for Installing Prometheus on CentOS 7

Prometheus is an open-source monitoring system developed by SoundCloud which stores all its data in a time-series database.

And it also allows a multi-dimensional data-model and a powerful query language ensuring to generate more accurate reports.

To set up this monitoring we need to have one 64-bit CentOS 7 server and a non-root sudo user.

 

Steps for Installing Prometheus

The following steps are used by our Support Techs to complete the setup.

1.  Installing Prometheus Server

a. Create a new ‘prometheus’ user with the following command:

$ useradd -m -s /bin/bash prometheus

b. Then update the system with the following command:

$ yum update -y

c. After that we need to download the latest build of the Prometheus server and time-series database using the below command:

$ curl -LO "https://github.com/prometheus/prometheus/releases/download/0.16.0/prometheus-0.16.0.linux-amd64.tar.gz"

d. Then run the following commands:

$ mkdir ~/Prometheus
$ cd ~/Prometheus
$ tar -xvzf ~/Downloads/prometheus-0.16.0.linux-amd64.tar.gz

e. We can verify the installation with the following command:

$ ~/Prometheus/prometheus-0.16.0.linux-amd64/prometheus -version

The result can be seen as shown below:

prometheus, version 0.16.0 (branch: HEAD, revision: dcb8ba4)
build user: julius@desktop
build date: 20151009-23:51:17
go version: 1.5.1

2. Installing Node Exporter

Node Exporter exports lots of metrics such as disk I/O statistics, CPU load, memory usage, network statistics, and more in a format Prometheus understands.

We can install this by giving the following commands:

$ cd ~/Downloads && curl -LO "https://github.com/prometheus/node_exporter/releases/download/0.11.0/node_exporter-0.11.0.linux-amd64.tar.gz"
$ mkdir ~/Prometheus/node_exporter
$ cd ~/Prometheus/node_exporter
$ tar -xvzf ~/Downloads/node_exporter-0.11.0.linux-amd64.tar.gz

 

3. Running Node Exporter as a Service

a. We can use the following commands to run Node Exporter as a service.

$ sudo vi /etc/systemd/system/node_exporter.service

b. And add the following:

/etc/init/node_exporter.conf

[Unit]
Description=Node Exporter

[Service]
User=prometheus
ExecStart=/home/prometheus/Prometheus/node_exporter/node_exporter

[Install]
WantedBy=default.target

 

c. Then provide the following commands:

$ sudo systemctl daemon-reload
$ sudo systemctl enable node_exporter.service
$ sudo systemctl start node_exporter.service

[Need assistance? We can help you!]

4. Starting Prometheus Server

Before we start Prometheus, we can create a configuration file for it called prometheus.yml.

$ cd ~/Prometheus/prometheus-0.16.0.linux-amd64

$ vi ~/Prometheus/prometheus-0.16.0.linux-amd64/prometheus.yml

And copy the following code into the file:

scrape_configs:
- job_name: "node"
scrape_interval: "15s"
target_groups:
- targets: ['localhost:9100']

Then open port 9090 for the Prometheus access using firewall-cmd commands below.

$ firewall-cmd --add-port=9090/tcp --permanent
$ firewall-cmd --reload

 

5. Installing PromDash

One way to visualize the data in Prometheus’s time-series database is to use PromDash.

We can install this by giving the following commands:

$ cd ~/Prometheus
$ sudo yum install git ruby ruby-devel sqlite-devel zlib-devel gcc gcc-c++ automake patch
$ git clone https://github.com/prometheus/promdash.git
$ cd ~/Prometheus/promdash
$ gem install bundler
$ bundle install --without mysql postgresql

As we are configuring PromDash to work with SQLite3, we must ensure to exclude the gems for MySQL and PostgreSQL using the –without parameter.

Once done, we can see the following messages:

. . .
Your bundle is complete!
Gems in the groups mysql and postgresql were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

 

6. Setting Up the Rails Environment

We have to create a directory to store the SQLite3 databases associated with PromDash.

$ mkdir ~/Prometheus/databases

Type in the following to  PromDash create a SQLite3 database called mydb.sqlite3 inside the databases directory:

$ echo "export DATABASE_URL=sqlite3:$HOME/Prometheus/databases/mydb.sqlite3" >> ~/.bashrc

To set the RAILS_ENV environment variable to production.:

$ echo "export RAILS_ENV=production" >> ~/.bashrc

Apply the changes we made to the .bashrc file.

$ . ~/.bashrc

Next, we need to create PromDash’s tables in the SQLite3 database using the rake tool.

$ rake db:migrate

For precompiling give the following:

$ rake assets:precompile

[Need assistance? We can help you!]

7. Starting and Configuring PromDash

Start the server as a daemon with the following command:

$ bundle exec thin start -d

We need to wait for a few seconds for the server to start and then check  http://your_server_ip:3000/ to view PromDash’s homepage.

Then click New Server, then in the form, we can give any name for the Prometheus server. Set the URL field to http://your_server_ip:9090 and the Server type field to Prometheus.

Finally, click on Create Server to complete the configuration.

 

8. Creating a Dashboard

The dashboard already has one graph, but it needs to be configured.

Hovering over the graph’s header (which says Title) will reveal various icons that let you configure the graph.

To change its title, we can click on the Graph and Axis Settings icon (fourth from the left) and type in a new title in the Graph Title field.

Click on the Datasources icon, which is the second to the left, to add one or more expressions to the graph.

Then click Add Expression, and enter nodeprocsrunning.

Now click on the Refresh icon in the graph’s header to update the graph.

We can add more graphs by clicking on the Add Graph button at the bottom.

After making all the changes we can Save Changes to make the changes permanent.

[Need assistance? We can help you!]

 

Conclusion

In short, saw how to install Prometheus on CentOS 7 along with the method used by  Support Engineers for the setup.

 

 

 

 

 

 

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF