Monitoring Instance with Prometheus and Grafana

Prometheus section
  1. Login to the server with root access.
  2. Update and upgrade system : yum -y update; yum -y upgrade
  3. Download and Install Prometheus :
    - [[email protected]]# wget https://github.com/prometheus/prometheus/releases/download/v2.9.2/prometheus-2.9.2.linux-amd64.tar.gz 
    - [[email protected]]# tar xvfz prometheus-2.92.linux-amd64.tar.gz
    - [[email protected]]# mv prometheus-2.92.linux-amd64 prometheus
    - [[email protected]]# cd prometheus
    - [[email protected]]# cat prometheus.yaml #basic configuration

  4. Start prometheus service : ./prometheus --config.file=prometheus.yml
  5. Open firewall tcp port 9090
Client Section, monitoring other Linux machine
  1. Login to the client machine
  2. Download, extract, and running the node exporter
    [[email protected]]# wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
    [[email protected]]# tar xzvf node_exporter-0.17.0.linux-amd64.tar.gz
    [[email protected]]# mv node_exporter-0.17.0.linux-amd64.tar.gz node_exporter
    [[email protected]]# cd node_exporter
    [[email protected]]# ./node_exporter
  3. Set node_exporter as a service

    #reference : https://devopscube.com/monitor-linux-servers-prometheus-node-exporter/ 
    [[email protected]]# cp node_exporter /usr/local/bin
    [[email protected]]# useradd -rs /bin/false node_exporter
    [[email protected]]# cat > /etc/systemd/system/node_exporter.service

    [Unit]
    Description=Node Exporter
    After=network.target

    [Service]
    User=node_exporter
    Group=node_exporter
    Type=simple
    ExecStart=/usr/local/bin/node_exporter

    [Install]
    WantedBy=multi-user.target

  4. Start daemon, node_exporter and enable autostart
    [[email protected]]# systemctl daemon-reload
    [[email protected]]# systemctl start node_exporter
    [[email protected]]# systemctl status node_exporter
    [[email protected]]# systemctl enable node_exporter
  5. Open firewall port 9100
  6. Make sure you can access node exporter metric via http://:9100/metrics
Prometheus section 2.0
  1. Login to the server with root access.
  2. CD to Prometheus directory
  3. Re-configure prometheus.yaml, add client scrape_configs
  4. Restart Prometheus service : ./prometheus --config.file=prometheus.yml
  5. Send Prometheus service to the background : ctrl +z and then bg
  6. Make sure client node_exporter status is active on Prometheus > Status > Targets
Grafana section (same server with prometheus)
  1. Login to the machine with root access
  2. Install grafana with yum : yum install https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm
  3. Start grafana service
    [[email protected]]# systemctl start grafana-server
    [[email protected]]# systemctl enable grafana-server
  4. Open firewall tcp port 3000
  5. Access Grafana dashboard on the browser : http://ip-address:3000
  6. Create Prometheus datasource (https://prometheus.io/docs/visualization/grafana/)
  7. Import dashboard template for monitoring linux machine with Prometheus, you can download the json file from this url : https://grafana.com/dashboards/159