Skip to content

Commit cc66572

Browse files
committed
🐛 Set default window for alerts to match frequency.
1 parent 7efd676 commit cc66572

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

simvue/run.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ def create_metric_range_alert(
17951795
rule: typing.Literal["is inside range", "is outside range"],
17961796
*,
17971797
description: str | None = None,
1798-
window: pydantic.PositiveInt = 5,
1798+
window: pydantic.PostiveInt | None = None,
17991799
frequency: pydantic.PositiveInt = 1,
18001800
aggregation: typing.Literal[
18011801
"average", "sum", "at least one", "all"
@@ -1823,8 +1823,9 @@ def create_metric_range_alert(
18231823
* is outside range - metric value falls outside of value range.
18241824
description : str, optional
18251825
description for this alert, default None
1826-
window : PositiveInt, optional
1827-
time period in seconds over which metrics are averaged, by default 5
1826+
window : PositiveInt | None, optional
1827+
time period in seconds over which metrics are averaged,
1828+
default of None sets this to be the same as frequency.
18281829
frequency : PositiveInt, optional
18291830
frequency at which to check alert condition in seconds, by default 1
18301831
aggregation : Literal['average', 'sum', 'at least one', 'all'], optional
@@ -1852,7 +1853,7 @@ def create_metric_range_alert(
18521853
name=name,
18531854
description=description,
18541855
metric=metric,
1855-
window=window,
1856+
window=window or frequency,
18561857
aggregation=aggregation,
18571858
notification=notification,
18581859
rule=rule,
@@ -1877,7 +1878,7 @@ def create_metric_threshold_alert(
18771878
rule: typing.Literal["is above", "is below"],
18781879
*,
18791880
description: str | None = None,
1880-
window: pydantic.PositiveInt = 5,
1881+
window: pydantic.PostiveInt | None = None,
18811882
frequency: pydantic.PositiveInt = 1,
18821883
aggregation: typing.Literal[
18831884
"average", "sum", "at least one", "all"
@@ -1904,8 +1905,9 @@ def create_metric_threshold_alert(
19041905
* is below - value is below threshold.
19051906
description : str, optional
19061907
description for this alert, default None
1907-
window : PositiveInt, optional
1908-
time period in seconds over which metrics are averaged, by default 5
1908+
window : PositiveInt | None, optional
1909+
time period in seconds over which metrics are averaged,
1910+
default of None sets this to be the same as frequency.
19091911
frequency : PositiveInt, optional
19101912
frequency at which to check alert condition in seconds, by default 1
19111913
aggregation : Literal['average', 'sum', 'at least one', 'all'], optional
@@ -1935,7 +1937,7 @@ def create_metric_threshold_alert(
19351937
description=description,
19361938
threshold=threshold,
19371939
rule=rule,
1938-
window=window,
1940+
window=window or frequency,
19391941
frequency=frequency,
19401942
aggregation=aggregation,
19411943
notification=notification,

0 commit comments

Comments
 (0)