Example configuration
^^^^^^^^^^^^^^^^^^^^^
-.. warning:: This module requires 'stats' module to be present and loaded.
-
.. code-block:: lua
modules = {
Defaults are 15 minutes window, 6 hours period.
.. tip:: Use period 0 to turn off prediction and just do prefetching of expiring records.
- That works even without the 'stats' module.
+ That works even without the :ref:`stats <mod-stats>` module.
+
+.. note:: Otherwise this module requires :ref:`stats <mod-stats>` module and loads it if not present.
Exported metrics
^^^^^^^^^^^^^^^^
^^^^^^^^^^
.. function:: predict.config({ window = 15, period = 24})
-
+
Reconfigure the predictor to given tracking window and period length. Both parameters are optional.
Window length is in minutes, period is a number of windows that can be kept in memory.
e.g. if a ``window`` is 15 minutes, a ``period`` of "24" means 6 hours.
log = {},
}
--- Load dependent modules
-if not stats then modules.load('stats') end
-- Calculate next sample with jitter [1-2/5 of window]
local function next_event()
if type(config) ~= 'table' then return end
if config.window then predict.window = config.window end
if config.period then predict.period = config.period end
+ -- Load dependent modules
+ if (predict.period or 0) ~= 0 and not stats then modules.load('stats') end
-- Reinitialize to reset timers
predict.deinit()
predict.init()