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!
Below are the steps to configure Zabbix 3 with Grafana. (For this, I am using CentOS7 minimal)
Zabbix
Step1: Install Apache, Mariadb & PHP
1 2 3 4 5 | 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
1 2 3 4 | systemctl start httpd systemctl start mariadb systemctl enable httpd systemctl enable mariadb |
Step3: Improve the security of your MySQL installation
1 | mysql_secure_installation |
Step3: Configure Yum Repository and install Zabbix
1 2 | 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
1 2 3 4 | CREATE DATABASE zabbixdb CHARACTER SET UTF8; GRANT ALL PRIVILEGES on zabbixdb.* to zabbix@localhost IDENTIFIED BY 'Password'; FLUSH PRIVILEGES; quit |
1 | cd /usr/share/doc/zabbix-server-mysql-3.0.3/ |
(Note: Zabbix version might be different based on the version you downloaded)
1 | zcat create.sql.gz | mysql -uzabbix -p zabbixdb |
Step5: Edit zabbix_server.conf with your database settings and start Zabbix server
1 2 3 4 5 6 7 8 | 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
1 2 3 | vi /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Dubai |
After making the changes, restart apache web server
1 | 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.
1 | semanage port -a -t http_port_t -p tcp 10051 |
1 2 3 4 | vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport <span class="m">80</span> -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport <span class="m">10050</span> -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport <span class="m">10051</span> -j ACCEPT |
Reboot the server
Using your FQDN, visit the zabbix web installer.
1 | 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:
1 2 | Username: admin Password: zabbix |
Note: Restart zabbix server to make sure all services works fine.
1 | 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
1 2 3 4 5 | 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
1 | http://yourwebdomain:3000/login |
Default credentials are
1 2 | 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
1 2 3 | 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.