zabgrab.services.retention

Warning when data is requested from before Zabbix deletes it.

Zabbix keeps each item’s raw values for its history storage period and its hourly trends for its trend storage period, then the housekeeper deletes them. A fetch reaching back further can’t return the older data, which is easy to mistake for a gap in monitoring, so zabgrab warns about it (and suggests hourly trends, which are usually kept much longer, for raw requests).

The periods come from the item settings. A server-wide housekeeping override can change them without the API showing it, so the warnings say data may be gone.

Functions

format_duration(seconds)

Format a duration compactly, in its largest whole unit up to days.

warn_beyond_retention(jobs, *, start, now, ...)

Warn about items whose data may be deleted from part of the requested range.

zabgrab.services.retention.format_duration(seconds)[source]

Format a duration compactly, in its largest whole unit up to days.

Parameters:

seconds (float) – The duration; negative durations show as 0s.

Returns:

str – The duration, rounded down.

Return type:

str

Examples

>>> format_duration(150 * 60), format_duration(14 * 86_400)
('2h', '14d')
zabgrab.services.retention.warn_beyond_retention(jobs, *, start, now, resolution, ui)[source]

Warn about items whose data may be deleted from part of the requested range.

Items sharing a storage period get one warning between them.

Parameters:
  • jobs (sequence of Job) – The items to fetch.

  • start (datetime) – The start of the requested range.

  • now (datetime) – The current time, which storage periods count back from.

  • resolution (Resolution) – Raw values (checked against the history period) or hourly trends (checked against the trend period).

  • ui (UI) – For the warnings.

Return type:

None