Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Scheduled Event #521

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Action sbt scalafmtAll
takapi327 committed Oct 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit dbdacfc21a869a41b133c42845ef90eb8ff52eea
Original file line number Diff line number Diff line change
@@ -132,7 +132,13 @@ object ScheduledEventConfiguration {
actionsSuppressorWaitPeriod: Option[Int],
actionsSuppressorExtensionPeriod: Option[Int]
): ScheduledEventConfiguration =
new Impl(description, metrics, alarmRule, actionsSuppressor, actionsSuppressorWaitPeriod, actionsSuppressorExtensionPeriod)
new Impl(
description,
metrics,
alarmRule,
actionsSuppressor,
actionsSuppressorWaitPeriod,
actionsSuppressorExtensionPeriod)

implicit val decoder: Decoder[ScheduledEventConfiguration] = Decoder.forProduct6(
"description",
@@ -144,12 +150,12 @@ object ScheduledEventConfiguration {
)(ScheduledEventConfiguration.apply)

private final case class Impl(
description: Option[String],
metrics: Option[List[ScheduledEventMetric]],
alarmRule: Option[String],
actionsSuppressor: Option[String],
actionsSuppressorWaitPeriod: Option[Int],
actionsSuppressorExtensionPeriod: Option[Int]
description: Option[String],
metrics: Option[List[ScheduledEventMetric]],
alarmRule: Option[String],
actionsSuppressor: Option[String],
actionsSuppressorWaitPeriod: Option[Int],
actionsSuppressorExtensionPeriod: Option[Int]
) extends ScheduledEventConfiguration {
override def productPrefix = "ScheduledEventConfiguration"
}
Original file line number Diff line number Diff line change
@@ -97,25 +97,26 @@ class ScheduledEventSuite extends FunSuite {
alarmName = "ServerCpuTooHigh",
operation = None,
configuration = ScheduledEventConfiguration(
description =Some( "Goes into alarm when server CPU utilization is too high!"),
metrics = Some(List(
ScheduledEventMetric(
id = "30b6c6b2-a864-43a2-4877-c09a1afc3b87",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "CPUUtilization",
namespace = "AWS/EC2"
),
period = 300,
stat = "Average"
)),
returnData = true,
expression = None,
label = None
)
)),
description = Some("Goes into alarm when server CPU utilization is too high!"),
metrics = Some(
List(
ScheduledEventMetric(
id = "30b6c6b2-a864-43a2-4877-c09a1afc3b87",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "CPUUtilization",
namespace = "AWS/EC2"
),
period = 300,
stat = "Average"
)),
returnData = true,
expression = None,
label = None
)
)),
alarmRule = None,
actionsSuppressor = None,
actionsSuppressorWaitPeriod = None,
@@ -231,47 +232,48 @@ class ScheduledEventSuite extends FunSuite {
operation = None,
configuration = ScheduledEventConfiguration(
description = Some("Goes into alarm if total network traffic exceeds 10Kb"),
metrics = Some(List(
ScheduledEventMetric(
expression = Some("SUM(METRICS())"),
id = "e1",
label = Some("Total Network Traffic"),
returnData = true,
metricStat = None
),
ScheduledEventMetric(
id = "m1",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "NetworkIn",
namespace = "AWS/EC2"
),
period = 300,
stat = "Maximum"
)),
returnData = false,
expression = None,
label = None
),
ScheduledEventMetric(
id = "m2",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "NetworkOut",
namespace = "AWS/EC2"
),
period = 300,
stat = "Maximum"
)),
returnData = false,
expression = None,
label = None
)
)),
metrics = Some(
List(
ScheduledEventMetric(
expression = Some("SUM(METRICS())"),
id = "e1",
label = Some("Total Network Traffic"),
returnData = true,
metricStat = None
),
ScheduledEventMetric(
id = "m1",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "NetworkIn",
namespace = "AWS/EC2"
),
period = 300,
stat = "Maximum"
)),
returnData = false,
expression = None,
label = None
),
ScheduledEventMetric(
id = "m2",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "NetworkOut",
namespace = "AWS/EC2"
),
period = 300,
stat = "Maximum"
)),
returnData = false,
expression = None,
label = None
)
)),
alarmRule = None,
actionsSuppressor = None,
actionsSuppressorWaitPeriod = None,
@@ -366,31 +368,32 @@ class ScheduledEventSuite extends FunSuite {
operation = None,
configuration = ScheduledEventConfiguration(
description = Some("Goes into alarm if CPU Utilization is out of band"),
metrics = Some(List(
ScheduledEventMetric(
id = "m1",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "CPUUtilization",
namespace = "AWS/EC2"
),
period = 60,
stat = "Average"
)),
returnData = true,
expression = None,
label = None
),
ScheduledEventMetric(
id = "ad1",
expression = Some("ANOMALY_DETECTION_BAND(m1, 0.8)"),
label = Some("CPUUtilization (expected)"),
returnData = true,
metricStat = None
)
)),
metrics = Some(
List(
ScheduledEventMetric(
id = "m1",
metricStat = Some(
ScheduledEventMetricStat(
metric = Metric(
dimensions = Map("InstanceId" -> "i-12345678901234567"),
name = "CPUUtilization",
namespace = "AWS/EC2"
),
period = 60,
stat = "Average"
)),
returnData = true,
expression = None,
label = None
),
ScheduledEventMetric(
id = "ad1",
expression = Some("ANOMALY_DETECTION_BAND(m1, 0.8)"),
label = Some("CPUUtilization (expected)"),
returnData = true,
metricStat = None
)
)),
alarmRule = None,
actionsSuppressor = None,
actionsSuppressorWaitPeriod = None,
@@ -478,7 +481,8 @@ class ScheduledEventSuite extends FunSuite {
value = "ALARM",
reason =
"arn:aws:cloudwatch:us-east-1:123456789012:alarm:SuppressionDemo.EventBridge.FirstChild transitioned to ALARM at Friday 22 July, 2022 15:57:45 UTC",
reasonData = "{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:ServerCpuTooHigh\",\"state\":{\"value\":\"ALARM\",\"timestamp\":\"2022-07-22T15:57:45.394+0000\"}}]}",
reasonData =
"{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:ServerCpuTooHigh\",\"state\":{\"value\":\"ALARM\",\"timestamp\":\"2022-07-22T15:57:45.394+0000\"}}]}",
timestamp = OffsetDateTime.parse("2022-07-22T15:57:45.394+0000", formatter)
)
),
@@ -487,7 +491,8 @@ class ScheduledEventSuite extends FunSuite {
value = "OK",
reason =
"arn:aws:cloudwatch:us-east-1:123456789012:alarm:SuppressionDemo.EventBridge.Main was created and its alarm rule evaluates to OK",
reasonData = Some("{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:TotalNetworkTrafficTooHigh\",\"state\":{\"value\":\"OK\",\"timestamp\":\"2022-07-14T16:28:57.770+0000\"}},{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:ServerCpuTooHigh\",\"state\":{\"value\":\"OK\",\"timestamp\":\"2022-07-14T16:28:54.191+0000\"}}]}"),
reasonData = Some(
"{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:TotalNetworkTrafficTooHigh\",\"state\":{\"value\":\"OK\",\"timestamp\":\"2022-07-14T16:28:57.770+0000\"}},{\"arn\":\"arn:aws:cloudwatch:us-east-1:123456789012:alarm:ServerCpuTooHigh\",\"state\":{\"value\":\"OK\",\"timestamp\":\"2022-07-14T16:28:54.191+0000\"}}]}"),
timestamp = OffsetDateTime.parse("2022-07-22T15:56:14.552+0000", formatter)
)
),
@@ -498,7 +503,7 @@ class ScheduledEventSuite extends FunSuite {
actionsSuppressorExtensionPeriod = Some(180),
metrics = None,
description = None
),
)
),
`replay-name` = None
)