Create an awesome server monitoring dashboard with Zabbix and Grafana

A tutorial on creating an awesome monitoring dashboard using Zabbix & Grafana. I always wanted to setup a good monitoring tool for our servers and finally managed to setup Zabbix. A monitoring tool is a must for any IT pro who manages servers. With a tool like Zabbix you get an overall summary of all your servers health and furthermore helps you keep track of any major changes.

Zabbix is an enterprise-class open source distributed monitoring solution. It monitors the health of your servers and notifies you in case of issues. On top of it, Zabbix offers excellent reporting and data visualization features. And the best part, Zabbix is free of cost and in addition to that with Grafana, the whole system is even cooler!

Zabbix-Sample-Dashboard

Below are the steps to configure Zabbix 3 with Grafana. (For this, I am using CentOS7 minimal)

Zabbix

Step1: Install Apache, Mariadb & PHP

yum -y install httpd httpd-devel

yum -y install mariadb-server mariadb

yum -y install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml

Step2: Start all services, enable to be started on boot up

systemctl start httpd
systemctl start mariadb
systemctl enable httpd
systemctl enable mariadb

Step3: Improve the security of your MySQL installation

mysql_secure_installation

Step3: Configure Yum Repository and install Zabbix

rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql

Step4: Create zabbix database and import initial schema and data

CREATE DATABASE zabbixdb CHARACTER SET UTF8;
GRANT ALL PRIVILEGES on zabbixdb.* to zabbix@localhost IDENTIFIED BY 'Password';
FLUSH PRIVILEGES;
quit
cd /usr/share/doc/zabbix-server-mysql-3.0.3/

(Note: Zabbix version might be different based on the version you downloaded)

zcat create.sql.gz | mysql -uzabbix -p zabbixdb

Step5: Edit zabbix_server.conf with your database settings and start Zabbix server

vi /etc/zabbix/zabbix_server.conf

DBHost=localhost
DBName=zabbixdb
DBUser=zabbix
DBPassword=Password

systemctl start zabbix-server

Step5: Edit the PHP configuration for Zabbix front-end and update the timezone

vi /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Dubai

After making the changes, restart apache web server

systemctl restart httpd

Step6: Complete the setup using Zabbix web installer
 
For the web installer to be accessible over the internet, first need to make sure that the ports are allowed through the firewall and selinux.

semanage port -a -t http_port_t -p tcp 10051
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT

Reboot the server
 Using your FQDN, visit the zabbix web installer.

http://yourwebdomain/zabbix/

and follow the steps as shown below

Zabbix Welcome Screen- Click Next

Pre-Requisite Checks- If any of these fails, please correct it and run check again

Enter DB credentials and Click Next

Give your Zabbix server an apt name and click Next

Check the Pre-Installation Summary and if all looks fine click Next

Finally, click Finish and finalize the installation

Congratulations, your Zabbix installation is now complete and you can login to Zabbix with the default credentials as given below:

Username: admin
Password: zabbix

Note: Restart zabbix server to make sure all services works fine.

systemctl restart zabbix-server

Default Zabbix login will be similar to this

Grafana

Lets now install Grafana and bring some awesomeness to your dashboards.

Download and install Grafana, start, enable the service on next boot-up

yum install https://grafanarel.s3.amazonaws.com/builds/grafana-3.1.0-1468321182.x86_64.rpm

systemctl start grafana-server

systemctl enable grafana-server.service

Once installed you can browser Grafana with the below url

http://yourwebdomain:3000/login

Default credentials are

Username: admin
Password: admin

It is recommended to change the default password to something stronger.

Now that you have Grafana installed, lets install the Zabbix plugin to connect to our Zabbix installation. Restart Grafana service after the plugin installation

grafana-cli plugins install alexanderzobnin-zabbix-app

systemctl start grafana-server

Once the plugin is installed, we need to enable it.

That’s it! Your Zabbix installation is now ready with Grafana. I would be writing another post in detail on how to get graphs and charts using Zabbix with Grafana.