What is Prometheus? 

Prometheus is an open source, metrics-based monitoring system.It records real-time metrics in a time series database.

A typical monitoring platform with Prometheus is composed of multiple tools,

1.Multiple Exporters that typically run on the monitored host to export local metrics.
2.Prometheus to centralize and store the metrics.
3.Alertmanager to trigger alerts based on those metrics.
4.Grafana to produce dashboards.
5.PromQL is the query language used to create dashboard and alerts.

Requirements :

OS : centos 7.6

Installation :

Step 1 :

Update the OS to latest and disable SELINUX.

#yum update -y

#vi /etc/sysconfig/selinux

change  "SELINUX=enforcing"  to "SELINUX=disabled"

Reboot the server.

Step 2 :

Create a Prometheus user,

#sudo useradd --no-create-home --shell /bin/false prometheus

Step 3 :

Create the required directories and change the owenership,

#mkdir /etc/prometheus

#mkdir /var/lib/prometheus

#chown prometheus:prometheus /etc/prometheus

#chown prometheus:prometheus /var/lib/prometheus

Step 4 : 

Install wget and download the latest prometheus from here, https://prometheus.io/download/

#yum install wget -y

#wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz

Extract the downloaded file,

#tar -xvzf  prometheus-2.12.0.linux-amd64.tar.gz

Copy the below files from extracted directory to the required directories,

#cp -r prometheus-2.12.0.linux-amd64/prometheus /usr/local/bin
#cp -r prometheus-2.12.0.linux-amd64/promtool /usr/local/bin

#cp -r prometheus-2.12.0.linux-amd64/consoles /etc/prometheus
#cp -r prometheus-2.12.0.linux-amd64/console_libraries/ /etc/prometheus

#chown -R prometheus:prometheus /etc/prometheus/consoles
#chown -R prometheus:prometheus /etc/prometheus/console_libraries


Step 5 :

Setup Prometheus configuration,

#vi /etc/prometheus/prometheus.yml

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:

      - targets: ['localhost:9090']

Save and exit.

Change the ownership of the file,

#chown prometheus:prometheus /etc/prometheus/prometheus.yml

Step 6 :

Configuring Prometheus as service,

#vi /etc/systemd/system/prometheus.service

copy the following content to the file.

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Environment="GOMAXPROCS=2"
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --web.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries \
  --web.listen-address=0.0.0.0:9090 \
  --web.external-url=

SyslogIdentifier=prometheus
Restart=always

[Install]

WantedBy=multi-user.target

Save and exit.

Reload systemd system,

#systemctl daemon-reload

Start Prometheus,

#systemctl start prometheus

Check the status of Prometheus,

#systemctl status prometheus


Step 7 :

Access Prometheus Web UI,

Allow firewall to access Prometheus at outside.

Now go to browser and access the Prometheus web UI,

http://localhost:9090 or http://Prometheus IP :9090















Thats it, Prometheus installation and configuration has been completed in centOS 7.


Post a Comment

Previous Post Next Post