Ad Widget

Collapse

Archive old data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mario.almeida
    Member
    • Nov 2008
    • 44

    #1

    Archive old data

    Hi All,

    How would I archive 5 months old data from db (mysql)?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    If you're looking for your trend data which is older than 5 months you will do something like the following: (mysql)

    select * from trends where clock<UNIXTIME((now() - INTERVAL 5 MONTHS)); That

    will should pull all data from the trends table which is older than 5 months. There is a second trends table trends_uint. The history tables should only contain data up to the time set in the item's configuration history retention time.

    Hope that helps.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • mario.almeida
      Member
      • Nov 2008
      • 44

      #3
      SELECT * from trends where clock<=UNIX_TIMESTAMP(NOW() - INTERVAL 5 MONTH) LIMIT 10;

      The query you gave above do not show much data.

      Actual disk space utilize by zabbix database is 21GB. I have limited space need to purge some old data in a sql file.

      how to find which table is with more space.

      Comment

      • zabbix_zen
        Senior Member
        • Jul 2009
        • 426

        #4
        Hi / Olá.

        The trends table as the name suggests keeps only the trends(hourly averages of your gathered data).

        To easily find the largest tables why don't you try accessing the DB using a GUI tool like HeidiSQL or MySQL-Admin?

        Anyways,
        the largest ones will be history, history_uint and events.
        Remember you shouldn't mess with the DB without being sure what you're doing.
        You can also tweak how long Zabbix will keep each items data when creating/configuring them typing your intended
        'Keep history (in days)' and
        'Keep trends (in days)'

        Comment

        Working...