improve logging of spike detection.
@@ -83,28 +83,31 @@ class PluginManager:
historicalData['cnt'] += 1
cnt = historicalData['cnt']
- if val < val_thres:
- logger.debug('Current activity {} is below threshold level {}'.format(val, val_thres))
- return None
-
if cnt <= min_cnt:
logger.debug('Not enough data to detect a {} spike'.format(event))
return None
+ if val < val_thres:
+ logger.debug('Current activity {} is below threshold level {}'.format(val, val_thres))
+ return None
+
log_base = 10
if use_weighted_borders_coeff and cnt > log_base:
# Weighted coefficient allows to adapt borders in accordance to values,
# growing values leads to lower borders.
borders_coeff /= math.log(cnt, log_base)
- if (val / borders_coeff) <= newVal <= (val * borders_coeff):
+
+ lower_bound = val / borders_coeff
+ higher_bound = val * borders_coeff
+ if lower_bound <= newVal <= higher_bound:
logger.debug(
- '{}: New value {} is within bounds. Average: {}'.format(
- event, newVal, val))
+ '{}: Actual value {} is within bounds [{}, {}]. Expected value: {}'.format(
+ event, newVal, lower_bound, higher_bound, val))
return None
message = '{} suspicious spike has been noticed on node {} at {}. ' \
- 'Usual: {}. New: {}.'\
- .format(event, nodeName, time.time(), val, newVal)
+ 'Actual: {}. Expected: {}. Bounds: [{}, {}].'\
+ .format(event, nodeName, time.time(), newVal, val, lower_bound, higher_bound)
logger.debug(message)
return self._sendMessage(event, message)
