MCPcopy
hub / github.com/YelpArchive/elastalert / append

Method append

elastalert/ruletypes.py:316–327  ·  view source on GitHub ↗

Add an event to the window. Event should be of the form (dict, count). This will also pop the oldest events and call onRemoved on them until the window size is less than timeframe.

(self, event)

Source from the content-addressed store, hash-verified

314 self.running_count = 0
315
316 def append(self, event):
317 """ Add an event to the window. Event should be of the form (dict, count).
318 This will also pop the oldest events and call onRemoved on them until the
319 window size is less than timeframe. """
320 self.data.add(event)
321 self.running_count += event[1]
322
323 while self.duration() >= self.timeframe:
324 oldest = self.data[0]
325 self.data.remove(oldest)
326 self.running_count -= oldest[1]
327 self.onRemoved and self.onRemoved(oldest)
328
329 def duration(self):
330 """ Get the size in timedelta of the window. """

Callers 15

test_eventwindowFunction · 0.95
hitsFunction · 0.80
test_spikeFunction · 0.80
test_spike_query_keyFunction · 0.80
record_argsFunction · 0.80
generate_hitsFunction · 0.80
loadMethod · 0.80
load_yamlMethod · 0.80
load_optionsMethod · 0.80
load_modulesMethod · 0.80
get_namesMethod · 0.80
send_metricMethod · 0.80

Calls 1

durationMethod · 0.95

Tested by 8

test_eventwindowFunction · 0.76
hitsFunction · 0.64
test_spikeFunction · 0.64
test_spike_query_keyFunction · 0.64
record_argsFunction · 0.64
generate_hitsFunction · 0.64
mock_hitsMethod · 0.64
get_idMethod · 0.64