Thursday, August 31, 2023

PROMETHEUS | GRAFANA AND NODE EXPORTER CONFIGURATION

 



SETUP PROMETHEUS, NODE EXPORTER AND GRAFANA.

Follow the path and configure the Prometheus server 


VAGRANTFILE CODE:

Vagrant.configure("2") do |config|
    config.vm.define "prometheus" do |prometheus|
        prometheus.vm.box_download_insecure = true
        prometheus.vm.box = "hashicorp/bionic64"
        prometheus.vm.network "private_network", ip: "100.0.0.1"
        prometheus.vm.network "forwarded_port", guest: 9090, host:9090
        prometheus.vm.network "forwarded_port", guest: 9100, host:9100
        prometheus.vm.network "forwarded_port", guest: 3000, host:3000
        prometheus.vm.hostname = "prometheus"
        prometheus.vm.provider "virtualbox" do |v|
        v.name = "prometheus"
        v.memory = 2048
        v.cpus = 2
      end
    end

   config.vm.define “remote1” do |remote1|
     remote1.vm.box_download_insecure = true
     remote1.vm.box = “hashicorp/bionic64”
     remote1.vm.network “private_network”, ip: “100.0.0.2”
     remote1.vm.hostname = “remote1”
     remote1.vm.provider “virtualbox” do |v|
        v.name = “remote1”
        v.memory = 2048
        v.cpus = 2
      end
    end

  end

 

 VAGRANT STATUS:

vagrant status

SSH TO THE PROMETHEUS SERVER:

vagrant ssh prometheus
 

INSTALLATION OF PROMETHEUS

Download Page --> https://prometheus.io/download/
 
 

Copy the link and execute.

wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
 
  
 

Unzip.

tar xvfz prometheus-2.45.0.linux-amd64.tar.gz

 

Start the prometheus server with the command

 

local host connected to the server.

 

INSTALL NODE EXPORTER

Copy the link address:

wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz

unzip the binary.

tar xvfz node_exporter-1.6.0.linux-amd64.tar.gz

Now start node.

./node_exporter

Adding node exporter scrap_configs to prometheus as a YAML Configuration

Code:
./node_exporter
global:
scrape_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets: ['localhost:9100']
 
 
Start the Prometheus server bypassing scrap_config with the help of –config.file flag
 
./prometheus --config.file=exporter-config.yml
 Node is up.
 

 

 

INSTALLING THE GRAFANA

Update the package info –

sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update 
sudo apt-get upgrade

error resolve:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

 

sudo apt-get install grafana-enterprise

Start the Grafana Server –

sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server

Installation complete:

 

UI:



No comments:

Post a Comment