Install and Configure Prometheus Server and Node Exporter in RHEL

Install and Configure Prometheus Server and Node Exporter

There are 3 importants components to make sure Prometheus is up and running. We need to install and configure

  1. Prometheus Server,
  2. Node Exporter, and
  3. Dashborad which can be PromDash or Grafana.

Step 1 – Install and configure Prometheus Server in RHEL 7

Download Prometheus
Download Prometheus from https://prometheus.io/download/. You can find 3 Prometheus package which is supported for darwin/linux and windows.

$ sudo -s
$ yum install wget -y
$ cd /opt/
$ wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz
$ tar -zxvf prometheus-2.3.2.linux-amd64.tar.gz
$ cd prometheus-2.3.2.linux-amd64

If you find following files….

[root@ip-172-31-21-164 prometheus-2.3.2.linux-amd64]# ls -1
LICENSE
NOTICE
console_libraries
consoles
prometheus
prometheus.yml
promtool

This completes the Prometheus installation.

Verify the installation by typing in the following command:

[root@ip-172-31-21-164 prometheus-2.3.2.linux-amd64]# ./prometheus --version
prometheus, version 2.3.2 (branch: HEAD, revision: 71af5e29e815795e9dd14742ee7725682fa14b7b)
build user: root@5258e0bd9cc1
build date: 20180712-14:02:52
go version: go1.10.3

Step 2 – Install and configure Prometheus Node Exporter in RHEL 7

In order to monitor the metrics of your RHEL server, you should install a tool called Node Exporter. Node Exporter, as its name suggests, exports lots of metrics (such as disk I/O statistics, CPU load, memory usage, network statistics, and more) in a format Prometheus understands.

cd /opt/
wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz
tar -zxvf node_exporter-0.16.0.linux-amd64.tar.gz
cd node_exporter-0.16.0.linux-amd64
nohup ./node_exporter &

Step 3 — Running Node Exporter as a Service
if you want to Running Node Exporter as a Service

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

[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/root/prometheus/node_exporter/node_exporter

[Install]
WantedBy=multi-user.target

# Save the file and exit the text editor.

Reload systemd so that it reads the configuration file you just created.

$ sudo systemctl daemon-reload

Enable it so that it starts automatically at boot time.

$ sudo systemctl enable node_exporter.service

You can now either reboot your server, or use the following command to start the service manually:

$ sudo systemctl start node_exporter.service

Once it starts, use a browser to view Node Exporter’s web interface, which is available at http://your_server_ip:9100/metrics. You should see a page with a lot of text:

Step 4 — Starting Prometheus Server

Enter the directory where you installed the Prometheus server:

$ cd /opt/prometheus-2.3.2.linux-amd64

Before you start Prometheus, you must first understand a configuration file for it called prometheus.yml.

[root@ip-172-31-21-164 prometheus-2.3.2.linux-amd64]# more prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:9090']

Whereas, This creates a scrape_configs section and defines a job called node. It includes the URL of your Node Exporter’s web interface in its array of targets. The scrape_interval is set to 15 seconds so that Prometheus scrapes the metrics once every fifteen seconds.

You could name your job anything you want, but calling it “node” allows you to use the default console templates of Node Exporter. Save the file and exit.

Start the Prometheus server as a background process.

$ nohup ./prometheus > prometheus.log 2>&1 &

You can view the last few lines of the file using the tail command:

$ tail prometheus.log

Once the server is ready, you will see the following messages in the file:

level=info ts=2018-08-21T11:47:38.56459183Z caller=web.go:415 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-08-21T11:47:38.569742672Z caller=main.go:543 msg="TSDB started"
level=info ts=2018-08-21T11:47:38.569767659Z caller=main.go:603 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2018-08-21T11:47:38.57069388Z caller=main.go:629 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2018-08-21T11:47:38.570724527Z caller=main.go:502 msg="Server is ready to receive web requests."

Use a browser to visit Prometheus’s homepage available at http://your_server_ip:9090. You’ll see the following homepage.

Step 5 — Verify Prometheus Server
To make sure that Prometheus server is scraping data from Node Exporter, click on the Graph tab at the top of the page. On the page that opens, type in the name of a metric (like up, for example) in the text field that says Expression. Then, press the blue Execute button. Click Graph (next to Console) just below, and you should see a graph for that metric:

More metric can be found from the Node Exporter host such as
http://X.X.X.X:9100/metrics

Prometheus has console templates that let you view graphs of a few commonly used metrics. These console template are accessible only if you set the value of job_name to “prometheus” in Prometheus’s configuration.

Visit http://your_server_ip:9090/consoles/prometheus.html to access the Node Console and click on your server, localhost:9100, to view its metrics.

Step 6 — Installing PromDash Or Grafana…..

Tagged : / / / / /

Install and Configure Grafana in RHEL 7

Install and Configure Grafana in RHEL 7

Step 1 – Download & Install Grafana
Download Grafana RPM file RPM for Linux from https://grafana.com/grafana/download?platform=linux

# RHEL 7

$ sudo yum install initscripts fontconfig -y
$ wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.2-1.x86_64.rpm
$ sudo yum localinstall grafana-5.2.2-1.x86_64.rpm

Step 2 – Understand Grafana Installation details in RHEL/CENTOS

  1. Installs binary to /usr/sbin/grafana-server
  2. Copies init.d script to /etc/init.d/grafana-server
  3. Installs default file (environment vars) to /etc/sysconfig/grafana-server
  4. Copies configuration file to /etc/grafana/grafana.ini
  5. Installs systemd service (if systemd is available) name grafana-server.service
  6. The default configuration uses a log file at /var/log/grafana/grafana.log
  7. The default configuration specifies an sqlite3 database at /var/lib/grafana/grafana.db

Step 3 – Start the server (init.d service)

$ sudo service grafana-server start

This will start the grafana-server process as the grafana user, which is created during package installation. The default HTTP port is 3000, and default user and group is admin.

Step 4 – Configure the Grafana server to start at boot time

$ sudo /sbin/chkconfig --add grafana-server
$ sudo systemctl enable grafana-server.service
$ systemctl daemon-reload
$ systemctl start grafana-server
$ systemctl status grafana-server

Step 5 – Grafana server Environment file
The systemd service file and init.d script both use the file located at /etc/sysconfig/grafana-server for environment variables used when starting the back-end. Here you can override log directory, data directory and other variables.

Step 6 – Grafana server Log
By default Grafana will log to /var/log/grafana

Step 7 – Grafana Database
The default configuration specifies a sqlite3 database located at /var/lib/grafana/grafana.db. Please backup this database before upgrades.

You can also use MySQL or Postgres as the Grafana database, as detailed on
http://docs.grafana.org/installation/configuration/#database

Step 8 – Grafana configuration
The configuration file is located at /etc/grafana/grafana.ini. Go the Configuration page for details on all those options. You can add following data sources

  1. Graphite
  2. InfluxDB
  3. OpenTSDB
  4. Prometheus

Step 9 – Server side image rendering
Server side image (png) rendering is a feature that is optional but very useful when sharing visualizations, for example in alert notifications.

$ sudo yum install fontconfig -y
$ sudo yum install freetype* -y
$ sudo yum install urw-fonts -y


Step 10 – Browse the dashboard
http://X.X.X.X.:3000/
Username – admin
Password – admin

Tagged : / / / / /

How to install chefDK in RHEL, Ubantu, Mac and Windows?

chefdk-installtion-process-rhel-ubantu-mac-windows
How to install chefDK in RHEL, Ubantu, Mac and Windows?
How to install chefDK in RHEL
Step 1: Download checfdk from https://downloads.chef.io/chef-dk/
or
> chmod 755 chefdk-0.9.0-1.el6.x86_64.rpm
Step 2: Install chef dk
> rpm -ivh chefdk-0.9.0-1.el6.x86_64.rpm
Step 3: Confirm your installation.
> which chef
> chef -v
Install folder is – /opt/chefdk
Tagged : / / / / / / / / / / / / / / / / / / /

Install SonaType SonaType Community Version

sonatype-nexus-community-version
Download & Install JDK 1.8
64 bit
# cd /opt/</div>
<div># wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.tar.gz"</div>
<div># tar xzf jdk-8u66-linux-x64.tar.gz
32 bit
# cd /opt/</div>
<div># wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-i586.tar.gz"</div>
<div># tar xzf jdk-8u66-linux-i586.tar.gz


Install SonaType Nexus Community Version

Download the Latest Package from http://www.sonatype.org/nexus/go/
TGZ – http://download.sonatype.com/nexus/3/latest-unix.tar.gz
ZIP – http://download.sonatype.com/nexus/oss/nexus-latest-bundle.zip

Install
https://support.sonatype.com/entries/20673251-Installing-Nexus-OSS

$ yum install wget
$ cd /opt/
$ wget http://download.sonatype.com/nexus/3/latest-unix.tar.gz
$ tar -zxvf latest-unix.tar.gz
$ mv nexus-3.12.1-01 nexus
$ cd nexus/bin
$ ./nexus start
$ ./nexus status

http://13.127.30.125:8081/
admin
admin123

Upgrade
https://support.sonatype.com/entries/23031188-How-do-I-upgrade-Nexus-OSS

Starting Nexus from the command line
https://support.sonatype.com/entries/20673271-Starting-Nexus-from-the-Command-Line

Execute ./bin/nexus ( ./bin/nexus.bat on Windows ) without any parameters to get the supported commands for controlling Nexus.

Open the Installation as – http://localhost:8081/nexus
Log In Dialog (default login/password is admin/admin123)”.

More
https://books.sonatype.com/nexus-book/reference/installing.html

Tagged : / / / / / /