Install Grafana in Linux CentOS 7 with Prometheus Data Source
Introduction
Grafana is a multi-platform open source analytics and interactive visualization web application.
Refer to Grafana official page to know more about this tools : https://grafana.com/docs/grafana/latest
Assumption
We'll use Grafana as visualization of our monitoring tools.
In this case, we'll use Grafana with Prometheus as data source.
We assumpt that we already have a monitoring server with Prometheus which called monitoring-server that already has node-exporter target.
And we'll install Grafana in same server with this Prometheus which already running.
Step by Step
Step 1 : Make Sure Selinux is Disable
Check selinux is disabled or enabled :
[root@monitoring-server ~]# getenforce
If it's enabled, disable it :
[root@monitoring-server ~]# vi /etc/sysconfig/selinux
Change SELINUX=enforcing
to SELINUX=disabled
, then reboot the server :
[root@monitoring-server ~]# reboot
Step 2 : Create Grafana Repo File
Create repo file :
[root@monitoring-server ~]# vi /etc/yum.repos.d/grafana.repo
Fill it with below :
[grafana] name=grafana baseurl=https://packages.grafana.com/oss/rpm repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packages.grafana.com/gpg.key sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt
Step 3 : Install Grafana
[root@monitoring-server ~]# yum install grafana
Step 4 : Install Related Fonts
[root@monitoring-server ~]# yum install fontconfig [root@monitoring-server ~]# yum install freetype* [root@monitoring-server ~]# yum install urw-fonts
Step 5 : Start and Enable Grafana
[root@monitoring-server ~]# systemctl start grafana-server [root@monitoring-server ~]# systemctl enable grafana-server [root@monitoring-server ~]# systemctl status grafana-server
Step 6 : Enable Grafana Port
[root@monitoring-server ~]# firewall-cmd --zone=public --permanent --add-port=3000/tcp [root@monitoring-server ~]# firewall-cmd --reload
Access Grafana page from http://monitoring-server:3000
How to Use
Login & Reset Default Password
Fresh Grafana will only have admin user with default password : admin.
Reset this default password with the secure one.
Add Prometheus Data Source
Go to data source page. Then add Prometheus as the data source.
Use Prometheus server address as the value. Like : http://monitoring-server:9090
Since we set Grafana in same server with Prometheus, we set the value as : http://localhost:9090
Set Grafana Dashboard
There are many types of Grafana dashboard.
As example in our assumption that we already have Prometheus with node-exporter target, we can set Grafana dashboard for node-exporter.
For node-exporter dashboard, we can import it with adding the dashboard code. Grafana dashboard code for node-exporter (full) : 1860.
Or we also can set the dashboard using the dashboard JSON file that we can download from Grafana official page.
If we already have Prometheus with various exporter targets, we also can set Grafana dashboard which suitable for it.