Ad Widget

Collapse

Does Zabbix Server Have a Way to Block Future-Dated Data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GChmurka
    Junior Member
    • Jun 2024
    • 21

    #1

    Does Zabbix Server Have a Way to Block Future-Dated Data?

    Hi all,

    I've encountered a strange issue and would appreciate any advice.

    One of my servers booted up with its system clock set 11 years into the future. During that time, zabbix_agent2 (active mode) sent data to the Zabbix server. Later, the system clock was sync to the current time.

    Now, when I look at "Latest data" in Zabbix, I can see values from 11 years in the future (since that was the most recent data received at that point).
    Click image for larger version  Name:	Zrzut ekranu z 2025-04-30 16-05-09.png Views:	0 Size:	55.9 KB ID:	502572

    As a result, I have a Problem item stuck with a "Resolved" status blinking - because the problem was "resolved" in the future. It looks like this will remain that way for the next 10+ years.

    Click image for larger version  Name:	Zrzut ekranu z 2025-04-30 16-26-52.png Views:	0 Size:	28.0 KB ID:	502573

    And problem desc. resolved time is in the future.Click image for larger version  Name:	Zrzut ekranu z 2025-04-30 16-07-09.png Views:	0 Size:	84.6 KB ID:	502574

    So my questions are:
    1. Does Zabbix have any built-in mechanism to reject or limit future-dated data? In the real world, a reasonable future tolerance would be maybe +14 hours (due to time zones).
    2. How can I fix this issue now without deleting the host (I don’t want to lose historical data)?
    3. Any suggestions or best practices to prevent this from happening again?

    Thanks in advance!
    Last edited by GChmurka; 30-04-2025, 16:34.
  • GChmurka
    Junior Member
    • Jun 2024
    • 21

    #2
    I quickly came up with a solution to block inserts into the database with future data on the mysql side.
    24h is a reasonable value that I can accept while waiting for new data to be overwritten

    Warning: I have to test it​

    Code:
    DELIMITER //
    
    -- Trigger 'history'
    CREATE TRIGGER trg_check_clock_history
    BEFORE INSERT ON history
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    -- Trigger 'history_bin'
    CREATE TRIGGER trg_check_clock_history_bin
    BEFORE INSERT ON history_bin
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    -- Trigger 'history_log'
    CREATE TRIGGER trg_check_clock_history_log
    BEFORE INSERT ON history_log
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    -- Trigger 'history_str'
    CREATE TRIGGER trg_check_clock_history_str
    BEFORE INSERT ON history_str
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    -- Trigger 'history_text'
    CREATE TRIGGER trg_check_clock_history_text
    BEFORE INSERT ON history_text
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    -- Trigger 'history_uint'
    CREATE TRIGGER trg_check_clock_history_uint
    BEFORE INSERT ON history_uint
    FOR EACH ROW
    BEGIN
    IF NEW.clock > UNIX_TIMESTAMP() + 86400 THEN
    SIGNAL SQLSTATE '45000'
    SET MESSAGE_TEXT = 'Insert drop (>24h)';
    END IF;
    END;
    //
    
    DELIMITER ;
    Last edited by GChmurka; 01-05-2025, 12:34.

    Comment

    Working...