Clean and reduce size of Zabbix database

Zabbix-monitoring-system

After some time you may find that you Zabbix database become enormously big and consumes significant amount of disk space. Among really usefull data there is data that may be cleaned up and optimized in Zabbix database in order to reduce size of Zabbix database.

Configure Zabbix Housekeeping

This settings determine how long to keep historical data in Zabbix tables.

Go to “Administration” -> “General” -> “Housekeeping”

zabbix-reduce-database-size

Default values are 365 days. Set this to lower value unless you really need to keep history for one year.

After that wait for Housekeeper’s procedure to complete. You can watch it in a log with:

Example output:

3050:20240202:121303.581 executing housekeeper
3050:20240202:121556.485 housekeeper [deleted 4847762 hist/trends, 31260 items/triggers, 116 events, 209 problems, 6 sessions, 0 alarms, 0 audit, 0 records in 172.903534 sec, idle for 1 hour(s)]

Housekeeper runs once per hour.

Now entries are deleted from tables but this will not result in free disk space amount as MySQL’s files will remain the same size. It’s like if we pour a water away from a bucket: there is little amount of water in the bucket but the bucket’s size is the same.

If you don’t want to wait for Housekeeper you can run these MySQL quieries:

Now we need to replace a “bucket” with a “bottle” and free up disk space.

Optimize (reduce) Zabbix tables

This can be done with MySQL “optimize” statement. It’s will defragment the table and squeeze the table’s file on a disk:

Here are the tables with istorycal data you need to optimize to reduce Zabbix database size:

Now check free space and you will notice a difference.

Good luck!

 

 

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com