Difference between revisions of "Install Prometheus in Linux CentOS 7"
Line 2: | Line 2: | ||
Prometheus is an open-source systems monitoring and alerting tool. | Prometheus is an open-source systems monitoring and alerting tool. | ||
+ | <br>Prometheus will work as monitoring server if monitoring target already set with Prometheus exporter. | ||
+ | <br>There are many types of exporter : node-exporter, nginx-exporter, postgres-exporter, etc. | ||
<br>Refer to Prometheus page to know more about this tools : https://prometheus.io/docs/introduction/overview | <br>Refer to Prometheus page to know more about this tools : https://prometheus.io/docs/introduction/overview | ||
Revision as of 21:15, 7 November 2020
Introduction
Prometheus is an open-source systems monitoring and alerting tool.
Prometheus will work as monitoring server if monitoring target already set with Prometheus exporter.
There are many types of exporter : node-exporter, nginx-exporter, postgres-exporter, etc.
Refer to Prometheus page to know more about this tools : https://prometheus.io/docs/introduction/overview
Step by Step
Step 1 : Prepare User & Group for Prometheus
[root@monitoring-server ~]# groupadd --system prometheus [root@monitoring-server ~]# useradd -s /sbin/nologin --system -g prometheus prometheus
Step 2 : Prepare Directories for Prometheus
[root@monitoring-server ~]# mkdir /var/lib/prometheus [root@monitoring-server ~]# for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done
Step 3 : Download Prometheus
[root@monitoring-server ~]# cd Temp [root@monitoring-server Temp]# curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi - [root@monitoring-server Temp]# tar xvf prometheus*.tar.gz [root@monitoring-server Temp]# cd prometheus* [root@monitoring-server Temp]# mv prometheus promtool /usr/local/bin/ [root@monitoring-server Temp]# mv prometheus.yml /etc/prometheus/prometheus.yml [root@monitoring-server Temp]# mv consoles/ console_libraries/ /etc/prometheus/
Step 4 : Set System Service
Create service file :
[root@monitoring-server ~]# vi /etc/systemd/system/prometheus.service
Fill with below value :
[Unit] Description=Prometheus Documentation=https://prometheus.io/docs/introduction/overview/ Wants=network-online.target After=network-online.target [Service] Type=simple Environment="GOMAXPROCS=1" 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
Make sure GOMAXPROCS value is same with real vcpus count in our prometheus server.
Step 5 : Set Prometheus Files Owner
[root@monitoring-server ~]# for i in rules rules.d files_sd; do sudo chown -R prometheus:prometheus /etc/prometheus/${i}; done [root@monitoring-server ~]# for i in rules rules.d files_sd; do sudo chmod -R 775 /etc/prometheus/${i}; done [root@monitoring-server ~]# chown -R prometheus:prometheus /var/lib/prometheus/
Step 6 : Start and Enable Prometheus
[root@monitoring-server ~]# systemctl daemon-reload [root@monitoring-server ~]# systemctl start prometheus [root@monitoring-server ~]# systemctl enable prometheus [root@monitoring-server ~]# systemctl status prometheus
Step 7 : Enable Prometheus Port
[root@monitoring-server ~]# firewall-cmd --zone=public --permanent --add-port=5000/tcp [root@monitoring-server ~]# firewall-cmd --reload
How to Access & Use
After al steps above done, access prometheus from browser : http://monitoring-server:9090
If we have done all the steps correctly, we can see the Prometheus page without any metric.
Next, we'll install node exporter into a target server that need to be monitored and connect it to this Prometheus.
For installing node exporter, follow this page :