From 67663b3433186a196f7b10b098372cc7c23ced19 Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 19:52:57 +0300 Subject: [PATCH 1/6] Add auto_resolve_after to Detect class --- signal_analog/flow.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/signal_analog/flow.py b/signal_analog/flow.py index cfefa16..0255f2f 100644 --- a/signal_analog/flow.py +++ b/signal_analog/flow.py @@ -992,7 +992,7 @@ def __init__(self): class Detect(Function): - def __init__(self, on, off=None, mode=None): + def __init__(self, on, off=None, mode=None, auto_resolve_after=None): """Creates a object. A 'detect' object is used to create events when a condition is met @@ -1012,9 +1012,13 @@ def __init__(self, on, off=None, mode=None): split - the on condition is evaluated only if there is no alert, and the alert is raised when the on condition evaluates to true. The off condition is only evaluated when the alert is raised, and the alert is cleared when the off condition evaluates to true. + auto_resolve_after: After any input data stream stops receiving data points for the specified duration, + the detector clears active alerts. """ super(Detect, self).__init__("detect") - self.args = [Arg(on), KWArg("off", off), KWArg("mode", mode)] + self.args = [Arg(on), + KWArg("off", off), KWArg("mode", mode), + KWArg("auto_resolve_after", auto_resolve_after)] class Op(Function): From 65d18251cdc8aa03ef5107d0758300d59d49007e Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 20:42:14 +0300 Subject: [PATCH 2/6] Avoid breaking RST markup --- signal_analog/flow.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/signal_analog/flow.py b/signal_analog/flow.py index 0255f2f..eaee57e 100644 --- a/signal_analog/flow.py +++ b/signal_analog/flow.py @@ -993,7 +993,7 @@ def __init__(self): class Detect(Function): def __init__(self, on, off=None, mode=None, auto_resolve_after=None): - """Creates a object. + """Creates an object. A 'detect' object is used to create events when a condition is met and when it clears. These events can be used to notify people of when @@ -1003,17 +1003,17 @@ def __init__(self, on, off=None, mode=None, auto_resolve_after=None): Arguments: on: Data when expression that will fire an event with the status "anomalous". off: Data when expression that will fire an event with the status "ok". If not specified then the 'off' is - equivalent to not on + equivalent to not on mode: String mode of the detector - paired - both on and off conditions are always evaluated simultaneously. The alert is raised if on - is true and off is false, and the alert is cleared if the off is true and on is false. + paired: both on and off conditions are always evaluated simultaneously. The alert is raised if on + is true and off is false, and the alert is cleared if the off is true and on is false. - split - the on condition is evaluated only if there is no alert, and the alert is raised when the - on condition evaluates to true. The off condition is only evaluated when the alert is raised, and - the alert is cleared when the off condition evaluates to true. + split: the on condition is evaluated only if there is no alert, and the alert is raised when the + on condition evaluates to true. The off condition is only evaluated when the alert is raised, and + the alert is cleared when the off condition evaluates to true. auto_resolve_after: After any input data stream stops receiving data points for the specified duration, - the detector clears active alerts. + the detector clears active alerts. """ super(Detect, self).__init__("detect") self.args = [Arg(on), From f605eeef3d2ed8b063276f87c785226a4d0f0983 Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 21:06:21 +0300 Subject: [PATCH 3/6] Reflect auto_resolve_after in tests --- tests/generators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/generators.py b/tests/generators.py index b7647a6..0a42415 100644 --- a/tests/generators.py +++ b/tests/generators.py @@ -78,7 +78,8 @@ def detects(draw): on = draw(flows()) off = draw(ascii()) mode = draw(sampled_from(["paired", "split"])) - return flow.Detect(on, off=off, mode=mode) + auto_resolve_after = draw(ascii()) + return flow.Detect(on, off=off, mode=mode, auto_resolve_after=auto_resolve_after) @composite From 0fbd4f968cb28505165d8003397554c223a92186 Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 21:07:52 +0300 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 909e89d..8a6b41d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.10.1 (2023-7-24) + +* Added `auto_resolve_after` parameter in `Detect` class. + ## 2.10.0 (2023-7-19) * Added `AmazonEventBridgeNotification` for Amazon EventBridge integration within detectors. From 0a53996b720cda8f21eb54204ba54b89aa01a2cf Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 21:14:39 +0300 Subject: [PATCH 5/6] =?UTF-8?q?Bump=20version:=202.10.0=20=E2=86=92=202.10?= =?UTF-8?q?.1.dev0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 2 +- setup.py | 2 +- signal_analog/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index cddec03..6a9ae43 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.10.0 +current_version = 2.10.1.dev0 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? diff --git a/setup.py b/setup.py index 2307d8a..e1634b4 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( name='signal_analog', - version='2.10.0', + version='2.10.1.dev0', description='A troposphere-like library for managing SignalFx' + 'Charts, Dashboards, and Detectors.', long_description=readme + '\n\n' + history, diff --git a/signal_analog/__init__.py b/signal_analog/__init__.py index 9f73602..e1be07a 100644 --- a/signal_analog/__init__.py +++ b/signal_analog/__init__.py @@ -9,7 +9,7 @@ __author__ = """Fernando Freire""" __email__ = 'Lst-nike.plus.platform.sharedinfrastructure@nike.com' -__version__ = '2.10.0' +__version__ = '2.10.1.dev0' logging_config = pkg_resources.resource_string( __name__, 'logging.yaml').decode('utf-8') From 968bc25fddca7e47506eb5d024a5b3ebbc14224c Mon Sep 17 00:00:00 2001 From: bebyx Date: Mon, 24 Jul 2023 21:15:30 +0300 Subject: [PATCH 6/6] =?UTF-8?q?Bump=20version:=202.10.1.dev0=20=E2=86=92?= =?UTF-8?q?=202.10.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 2 +- setup.py | 2 +- signal_analog/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6a9ae43..3180ae8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.10.1.dev0 +current_version = 2.10.1 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? diff --git a/setup.py b/setup.py index e1634b4..60ef867 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( name='signal_analog', - version='2.10.1.dev0', + version='2.10.1', description='A troposphere-like library for managing SignalFx' + 'Charts, Dashboards, and Detectors.', long_description=readme + '\n\n' + history, diff --git a/signal_analog/__init__.py b/signal_analog/__init__.py index e1be07a..707d252 100644 --- a/signal_analog/__init__.py +++ b/signal_analog/__init__.py @@ -9,7 +9,7 @@ __author__ = """Fernando Freire""" __email__ = 'Lst-nike.plus.platform.sharedinfrastructure@nike.com' -__version__ = '2.10.1.dev0' +__version__ = '2.10.1' logging_config = pkg_resources.resource_string( __name__, 'logging.yaml').decode('utf-8')