AI Preview
Is this content worth your time? Use the quick preview to decide.
Hi everyone,
In this guide, we install Zabbix with PostgreSQL and connect it to Grafana on two Ubuntu servers. We use the official package repositories, configure the database and web interface, and then set up the Zabbix data source in Grafana.
To verify the integration, we compare the Zabbix server uptime metric in Zabbix and a Grafana dashboard. We also explain the role of database credentials and a few connection-security options encountered during setup.
🔗 Helpful Links
- There are no helpful links in this one.
Video Tutorial


You need to accept cookies to watch this video.
Used Commands
Update package lists
sudo apt updateInstall PostgreSQL database
sudo apt install -y postgresqlAdd official Zabbix repository
wget https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu26.04_all.deb
sudo dpkg -i zabbix-release_latest_7.4+ubuntu26.04_all.debRefresh repository package lists
sudo apt updateInstall Zabbix components
sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.5-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent2Verify Zabbix version
zabbix_server --versionCreate PostgreSQL user
sudo -u postgres createuser --pwprompt zabbixCreate Zabbix database
sudo -u postgres createdb -O zabbix -E UTF8 -T template0 zabbixImport initial database schema
zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbixConfigure Zabbix server
sudo nano /etc/zabbix/zabbix_server.confConfigure Nginx frontend
sudo nano /etc/zabbix/nginx.confEnable and restart services
sudo systemctl enable zabbix-server zabbix-agent2 nginx php8.5-fpm
sudo systemctl restart zabbix-server zabbix-agent2 nginx php8.5-fpmCheck Zabbix server status
sudo systemctl status zabbix-server --no-pagerInstall required tools
sudo apt-get install -y apt-transport-https wget gnupgAdd Grafana signing key
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key
sudo chmod 644 /etc/apt/keyrings/grafana.ascAdd and refresh Grafana repository
echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get updateInstall Grafana package
sudo apt-get install grafanaStart and enable Grafana
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-serverQuiz
Full Transcript
Monitoring with Zabbix and Grafana
Hello everyone, and welcome to the Techaptic channel. Today we will install Zabbix, a widely used infrastructure monitoring platform. As you know, Zabbix is an open-source application with a strong community behind it. It already includes some very useful tools, but we want to take the visualization side a bit further, so we will install Grafana as well. Dashboards are very important in a monitoring platform because system administrators, NOC teams, and operations teams need clear overviews to make fast and accurate decisions.
Grafana works very well with Zabbix and lets us display the data it pulls through APIs in its own dashboards with a lot of flexibility. So in this video, we will install both products step by step and integrate them with each other. That is the main idea. The goal is to show you how to build this setup in your own environment and to create a foundation for the videos we will make later.
Lab design and resources
For this setup, I prepared two Ubuntu servers in my VMware lab. One hosts Zabbix together with the PostgreSQL database, and the other is dedicated to Grafana. Running Zabbix Server and the database on the same server is quite practical for small and medium-sized environments and will usually cover most needs. But in larger environments, as the number of hosts, monitored metrics, and the data collection frequency increase, you may need to move the database workload to another server. For hardware resources, we assigned the Zabbix server 8 GB of RAM, 2 vCPUs, and 80 GB of disk space.
For the Grafana server, we assigned 4 GB of RAM, 2 vCPUs, and 30 GB of disk space. These are not fixed or minimum values for every environment. They can change depending on the environment and your needs.
SSH and installation preparation
Now we can move on to the installation part. In general, these applications are installed by running specific commands and command sets. I will also share these commands on our website, so if you want, you can find them in the related article. Let’s start with the Zabbix server. I already assigned static IP addresses and enabled SSH access on the servers. Since the text in the virtual environment is small and I want you to see the commands more clearly, I will do the walkthrough from the Windows terminal. First, let’s connect to both servers over SSH in separate tabs. That way, we can switch between the servers more easily.
Installing PostgreSQL and Zabbix
The current stable Zabbix version is 7.4, and that’s the version we will use. Before that, though, we need to install and configure the database first. Let’s run this to download the latest package list. And then run the following command to install PostgreSQL. This will also install the packages PostgreSQL depends on. That part is done. Now we will add Zabbix’s official repository. So the Zabbix packages come from Zabbix instead of Ubuntu’s own repository. These commands are prepared for version 7.4. If you are installing a different Zabbix version in your environment, you will need to adjust the command set accordingly.
Now, since we added a new repository to the system, let’s run sudo apt update again to refresh the package list. Now we will install Zabbix server and components such as nginx and agent2 with a single command. That’s done. Let’s quickly check the Zabbix version. We can see that the version is 7.4.15. Everything looks good so far. Up to this point, we have installed the application and the database.
Configuring the Zabbix database
Now let’s move on to the configuration between the two. First, let’s create a PostgreSQL database user named zabbix. It is normal that the password doesn’t appear on the screen while you type it. And please make a note of this username and password because we will be asked for them later when we configure the DB integration on the Zabbix server. Now we will create a database for the Zabbix environment in PostgreSQL and give the user we created permission on this database. Let’s run the following command. You can see two Zabbix values here.
The one in the middle is the database username, while the Zabbix at the end of the line is the name of the database we are creating. And with the -O option, we are giving this user ownership of the database. We have created the database, but it is still empty. So we need to import the initial tables that come with the Zabbix package. Let’s run this command for this purpose. The process completed without any errors. Now the settings we made on the DB side need to be defined in Zabbix. For that, let’s open the Zabbix config file with nano. In this video, we use the database name and username that Zabbix expects by default.
So both are set to zabbix. If you want different values in your environment, make sure to update the related fields in this file as well. In this example setup, we will only change the password. A little further down, there is a DB user section. And below that, there is the DB password line. Just remove the comment marker in front of it, and then type the password that you specified earlier. Then press Ctrl+X and save the changes.
Configuring Nginx
Now let’s move to the Nginx. We included this component during the installation. Now we will configure the server name and the port used to publish the Zabbix frontend. Let’s open the Nginx config file. First, remove the comment markers from the listen and server_name lines and adjust these values in your environment. In this lab, I am going to publish the frontend on port 8080. In the listen line, I’ll leave that value as it is. For server name, I will enter the IP address of my Zabbix server. Let’s save the file with Ctrl+X again and exit.
Now let’s make sure these services start automatically when the server reboots and then restart them so the changes we made take effect. Before moving to the web interface, I also want to check the service status, so I will run the following command to check it. The service looks like it is running and we can move on to the web interface. Let’s open a web browser and type the URL with the port 8080 with the IP address of the Zabbix server.
Completing the Zabbix web setup
The Zabbix welcome screen is up. Let’s continue. On the check of prerequisites side, we shouldn’t be missing any prerequisites here. So let’s do a quick check first. Everything looks okay. Let’s continue. Now we will configure the database settings. The database type is already correct. So we will leave it as PostgreSQL. Since it is running on the same server as Zabbix, we don’t need to change the localhost value, and the database port can be left as 0 since we haven’t configured a specific port for the database communication. For the database name, we can leave it as zabbix as well.
But in your environment, if you change this value, please update it accordingly. We will leave the database schema empty.
Database authentication and security options
And with the way we have configured this setup, the credentials will be stored as plain text. If you use HashiCorp or CyberArk vaults in your environments, you can store the passwords more securely there. Of course, not every environment has one of these products. Let me add one more point here. If your design is like ours and Zabbix and PostgreSQL run together, there is a fourth option. You can make the application talk to the database without using a database password at all. PostgreSQL supports an authentication method called peer authentication by default. What does that mean?
For local connections, instead of checking a password, the database can verify the identity of the user running the connecting process through the kernel. In other words, Zabbix doesn’t need to keep a database password. Instead, PostgreSQL can check that the connection is actually coming from the Linux user we have allowed. First of all, this does require some additional authentication configuration on the PostgreSQL side. Additionally, I wouldn’t say it is more secure in every environment because you are moving the trust from a password to the operating system user identity.
But for a setup like this where everything runs on the same server, I think it is a much cleaner alternative than keeping the database password in plain text in a config file. Now let’s continue to our setup. Here it is asking for the database username and password. Let’s update this. By the way, why are we entering this information both in the config file and here in the web interface? The main reason is that Zabbix server and the web frontend are two separate components.
The values in the Zabbix Server configuration file are used by the Zabbix server service to connect to PostgreSQL, while the values we enter here are used by the PHP-based Zabbix frontend to access the database. So these settings are actually used for different functions. With that extra information, we can continue to the next step.
Finishing Zabbix setup and signing in
In the settings, let’s give the Zabbix server a name. I’ll just call it Zabbix. And set the timezone to plus three. But please make sure to adjust these settings according to your own environments. Let’s continue. This page shows a summary of the settings we configured. Everything looks fine. So we can continue and complete the installation. Okay. Now let’s sign into the interface. The default Zabbix username is Admin with a capital A. And the default password is zabbix, all lowercase. Especially in a production environment, I recommend changing the password after you sign in. As you can see, the interface is up.
And we can see some monitoring metrics from the Zabbix server on the dashboard. This is for the Zabbix side.
Installing Grafana
Now let’s move over to the Grafana. I’m not going to install Grafana from a deb package in one step. First, let’s run this command to prepare for using Grafana as an official repository. This way, we will also be able to get updates through that repository. Now let’s add the GPG key for the Grafana repository. So what’s GPG or GNU Privacy Guard? It’s a tool commonly used on Linux systems to verify digital signatures on packages. This way, APT or Advanced Package Tool will verify that the information it receives from the repository is signed by Grafana and it checks that the packages it downloads match the information from the trusted source.
We didn’t do this as a separate step for Zabbix because we configured its repository through the official release package. Grafana asked us to add the repository and signing key separately. So that’s why we defined the GPG key here. Finally, let’s add the Grafana stable channel to the system. We won’t use the other builds in this setup. Let’s paste this command set and enter. That’s done. Now it’s time to install Grafana. That’s done as well. Now let’s start the Grafana service and just like we did on the Zabbix server, make sure it starts automatically after a reboot. Now we can open Grafana and sign in.
We can access it over HTTP by using the default port 3000. Grafana’s default sign-in credentials are admin and admin, all lower case. But unlike Zabbix, Grafana asked us to change this password right away. So we will change it. As you can see, we can access the Grafana’s interface.
Integrating Grafana with Zabbix
Now we will integrate Zabbix with Grafana. First, let’s install the Zabbix plugin from the Grafana interface. To do that, go to the plugin section and search for the Zabbix. Click it, install it, and enable it. Then go to the connections and from there, open the data sources, click add data source, and search for Zabbix. And for the URL part, we won’t enter the server’s web URL. We will use the API endpoint instead. So enter the following value. The URL needs to end with api_jsonrpc.php. Also, please leave the HTTP authentication option at no authentication because this section is for the general HTTP layer.
We will configure the Zabbix API authentication below in the Zabbix connection section. So for that, select the user and password and specify the Zabbix credentials. For now, we don’t need to enter or change anything else here. We can click Save & Test to test these settings. It says the operation is successful and the settings have been saved as well. At this point, we don’t really have any other configuration steps left.
Validating monitoring data in a dashboard
But before I end the video, I want to use a small example to show that Grafana can actually pull monitoring data through the Zabbix API. Grafana comes with a few ready-made dashboards for Zabbix. We can access them from the dashboards under the data source. Since Zabbix is only monitoring its own server right now, we can import the Zabbix server dashboard. Now let’s switch back to the Zabbix and find a metric that we can check on both sides. Under monitoring, let’s open the latest data and from the host section, let’s select the Zabbix server. And for the name, let’s select uptime and filter the data.
The latest uptime value for this server is 2 hours and 56 minutes. Now let’s check whether the same metric is also displayed under the dashboard we imported into Grafana. Let’s go to the Grafana dashboards and click the dashboard that we have imported earlier. And as you can see, the uptime value we checked on the Zabbix side is also visible in the Grafana dashboard. With this cross-check, we have confirmed that the data can be pulled through the Zabbix API. Of course, in enterprise environments, these ready-made dashboards often aren’t used exactly as they are.
Both the metrics and the visualizations need to be customized based on the systems you are monitoring and your needs. That’s why we will make separate videos where we cover both Zabbix monitoring settings and the Grafana dashboards through real scenarios. That brings us to the end of this video. See you on the next one. Take care.
Rating




