-
Notifications
You must be signed in to change notification settings - Fork 239
Added the object representation of the CloudWatch Alarm #485
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...main/java/com/amazonaws/services/lambda/runtime/events/CloudWatchCompositeAlarmEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Represents an CloudWatch Composite Alarm event. This event occurs when a composite alarm is triggered. | ||
* | ||
* @see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-actions">Using Amazon CloudWatch alarms</a> | ||
*/ | ||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CloudWatchCompositeAlarmEvent { | ||
private String source; | ||
private String alarmArn; | ||
private String accountId; | ||
private String time; | ||
private String region; | ||
private AlarmData alarmData; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class AlarmData { | ||
private String alarmName; | ||
private State state; | ||
private PreviousState previousState; | ||
private Configuration configuration; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class State { | ||
private String value; | ||
private String reason; | ||
private String reasonData; | ||
private String timestamp; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class PreviousState { | ||
private String value; | ||
private String reason; | ||
private String reasonData; | ||
private String timestamp; | ||
private String actionsSuppressedBy; | ||
private String actionsSuppressedReason; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Configuration { | ||
private String alarmRule; | ||
private String actionsSuppressor; | ||
private Integer actionsSuppressorWaitPeriod; | ||
private Integer actionsSuppressorExtensionPeriod; | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...rc/main/java/com/amazonaws/services/lambda/runtime/events/CloudWatchMetricAlarmEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Represents an CloudWatch Metric Alarm event. This event occurs when a metric alarm is triggered. | ||
* | ||
* @see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-actions">Using Amazon CloudWatch alarms</a> | ||
*/ | ||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CloudWatchMetricAlarmEvent { | ||
private String source; | ||
private String alarmArn; | ||
private String accountId; | ||
private String time; | ||
private String region; | ||
private AlarmData alarmData; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class AlarmData { | ||
private String alarmName; | ||
private State state; | ||
private PreviousState previousState; | ||
private Configuration configuration; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class State { | ||
private String value; | ||
private String reason; | ||
private String timestamp; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class PreviousState { | ||
private String value; | ||
private String reason; | ||
private String reasonData; | ||
private String timestamp; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Configuration { | ||
private String description; | ||
private List<Metric> metrics; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Metric { | ||
private String id; | ||
private MetricStat metricStat; | ||
private Boolean returnData; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class MetricStat { | ||
private MetricDetail metric; | ||
private Integer period; | ||
private String stat; | ||
private String unit; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class MetricDetail { | ||
private String namespace; | ||
private String name; | ||
private Map<String, String> dimensions; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
aws-lambda-java-tests/src/test/resources/cloudwatch_composite_alarm.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"source": "aws.cloudwatch", | ||
"alarmArn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main", | ||
"accountId": "111122223333", | ||
"time": "2023-08-04T12:56:46.138+0000", | ||
"region": "us-east-1", | ||
"alarmData": { | ||
"alarmName": "CompositeDemo.Main", | ||
"state": { | ||
"value": "ALARM", | ||
"reason": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:CompositeDemo.FirstChild transitioned to ALARM at Friday 04 August, 2023 12:54:46 UTC", | ||
"reasonData": "{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:111122223333:alarm:CompositeDemo.FirstChild\",\"state\":{\"value\":\"ALARM\",\"timestamp\":\"2023-08-04T12:54:46.138+0000\"}}]}", | ||
"timestamp": "2023-08-04T12:56:46.138+0000" | ||
}, | ||
"previousState": { | ||
"value": "ALARM", | ||
"reason": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:CompositeDemo.FirstChild transitioned to ALARM at Friday 04 August, 2023 12:54:46 UTC", | ||
"reasonData": "{\"triggeringAlarms\":[{\"arn\":\"arn:aws:cloudwatch:us-east-1:111122223333:alarm:CompositeDemo.FirstChild\",\"state\":{\"value\":\"ALARM\",\"timestamp\":\"2023-08-04T12:54:46.138+0000\"}}]}", | ||
"timestamp": "2023-08-04T12:54:46.138+0000", | ||
"actionsSuppressedBy": "WaitPeriod", | ||
"actionsSuppressedReason": "Actions suppressed by WaitPeriod" | ||
}, | ||
"configuration": { | ||
"alarmRule": "ALARM(CompositeDemo.FirstChild) OR ALARM(CompositeDemo.SecondChild)", | ||
"actionsSuppressor": "CompositeDemo.ActionsSuppressor", | ||
"actionsSuppressorWaitPeriod": 120, | ||
"actionsSuppressorExtensionPeriod": 180 | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msailes is this change required in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. There was a warning in the build logs, I added these to remove the warning.