Install prometheus on centos7/rhel7

  1. Download prometheus monitoring tool. Latest downloads can be found at https://prometheus.io/download/

    curl -LO “https://github.com/prometheus/prometheus/releases/download/v1.7.1/prometheus-1.7.1.linux-amd64.tar.gz”

  2.  Untar the  file and move it to installation folder

    tar -xzvf prometheus-1.7.1.linux-amd64.tar.gz

  3. Move it to installation folder , here I am moving it to /var/lib

    mv prometheus-1.7.1.linux-amd64 /var/lib/prometheus

  4.  Edit the prometheus.yml file and update the scrape config– job_name: ‘server_monitoring’   scrape_interval: 15s   metrics_path: “/metrics”   static_configs:

        – targets:

            – server1:9100

            – server2:9100

            – server3:9100

          labels:

            service: servers_usage

       relabel_configs:

       – source_labels: [__address__]

         regex: ‘(.*)\:9108’

         target_label:  ‘instance’

         replacement:   ‘$1’

  5.  Add the start script in /etc/systemd/system/prometheus.service
    # echo “[Unit]
    Description=Prometheus Server
    Documentation=https://prometheus.io/docs/introduction/overview/
    After=network-online.target[Service]
    User=root
    Restart=on-failure
    ExecStart=/var/lib/prometheus/prometheus -config.file=/var/lib/prometheus/prometheus.yml -storage.local.path=/var/lib/prometheus/data[Install]
    WantedBy=multi-user.target”
  6. Start the prometheus service

    systemctl start prometheus

  7. Prometheus can now be accessible from http://<ip-address:9090

 

Install Grafana on CentOS/Rhel 7

  1. Download the rpm file

    wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.3-1.x86_64.rpm

  2.  install initscripts & fontconfig

     yum install initscripts fontconfig urw-fonts

  3.   Install Grafana rpm file

    rpm -ivh grafana-4.6.3-1.x86_64.rpm

  4.  Enable and start Grafana service

    systemctl enable grafana-server.service

    systemctl start grafana-server.service

  5.  After that Grafana can be accessed using the url http://<ipaddress>:3000/. Default username and password is admin / admin.