Skip to content

Commit af60b58

Browse files
committed
FIX: threshold expert: configure timeout using Redis cache mixin
When the Redis cache functionality was moved to a mixin, the code that set the cache timeout from the "timeout" parameter was removed, but the error checking and documentation remained. Change documentation and configuration checking code to refer to the standard redis_cache_ttl parameter instead. Also remove some redundant default values which are now set in the cache mixin. Fixes: 2a1b126 ("FIX: Use CacheMixins instead of lib.cache") Signed-off-by: Karl-Johan Karlsson <[email protected]>
1 parent 4de6607 commit af60b58

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

docs/user/bots.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3206,7 +3206,6 @@ Threshold
32063206
32073207
* `filter_keys`: String, comma-separated list of field names to consider or ignore when determining which messages are similar.
32083208
* `filter_type`: String, `whitelist` (consider only the fields in `filter_keys`) or `blacklist` (consider everything but the fields in `filter_keys`).
3209-
* `timeout`: Integer, number of seconds before threshold counter is reset.
32103209
* `threshold`: Integer, number of messages required before propagating one. In forwarded messages, the threshold is saved in the message as `extra.count`.
32113210
* `add_keys`: Array of string->string, optional, fields and values to add (or update) to propagated messages. Example:
32123211

intelmq/bots/experts/threshold/expert.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
2121
redis_cache_password: string. default: {None}
2222
23+
redis_cache_ttl: int, number of seconds to keep counts of similar
24+
messages.
25+
2326
filter_type: string ["whitelist", "blacklist"], when determining
2427
whether two messages are similar, consider either
2528
only the named fields, or all but the named fields
@@ -35,11 +38,6 @@
3538
long as the count is above the threshold, no new
3639
messages will be sent.
3740
38-
timeout: int, number of seconds to keep counts of similar
39-
messages. After this many seconds have elapsed, the count
40-
is deleted and "threshold" number of new messages will
41-
result in a new message being sent.
42-
4341
add_keys: optional, array of strings to strings, keys to add to
4442
forwarded messages. Regardless of this setting, the
4543
field "extra.count" will be set to the number of
@@ -59,19 +57,16 @@ class ThresholdExpertBot(ExpertBot, CacheMixin):
5957
filter_keys: Iterable = ["raw", "time.observation"]
6058
filter_type: str = "blacklist"
6159
redis_cache_db: int = 11
62-
redis_cache_host: str = "127.0.0.1" # TODO: could be ipaddress
63-
redis_cache_password: Optional[str] = None
64-
redis_cache_port: int = 6379
60+
redis_cache_ttl: int = 3600
6561
threshold: int = 100
66-
timeout: int = 3600
6762

6863
_message_processed_verb = 'Forwarded'
6964

7065
_is_multithreadable = False
7166
bypass = False
7267

7368
def init(self):
74-
if self.timeout <= 0:
69+
if self.redis_cache_ttl <= 0:
7570
raise ConfigurationError('Timeout', 'Invalid timeout specified, use positive integer seconds.')
7671
if self.threshold <= 0:
7772
raise ConfigurationError('Threshold', 'Invalid threshold specified, use positive integer count.')

0 commit comments

Comments
 (0)