Module aws_lambda_powertools.utilities.data_classes.cloud_watch_alarm_event

Classes

class CloudWatchAlarmConfiguration (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmConfiguration(DictWrapper):
    @property
    def description(self) -> Optional[str]:
        """
        Optional description for the Alarm.
        """
        return self.get("description", None)

    @property
    def alarm_rule(self) -> Optional[str]:
        """
        Optional description for the Alarm rule in case of composite alarm.
        """
        return self.get("alarmRule", None)

    @property
    def alarm_actions_suppressor(self) -> Optional[str]:
        """
        Optional action suppression for the Alarm rule in case of composite alarm.
        """
        return self.get("actionsSuppressor", None)

    @property
    def alarm_actions_suppressor_wait_period(self) -> Optional[str]:
        """
        Optional action suppression wait period for the Alarm rule in case of composite alarm.
        """
        return self.get("actionsSuppressorWaitPeriod", None)

    @property
    def alarm_actions_suppressor_extension_period(self) -> Optional[str]:
        """
        Optional action suppression extension period for the Alarm rule in case of composite alarm.
        """
        return self.get("actionsSuppressorExtensionPeriod", None)

    @property
    def metrics(self) -> Optional[List[CloudWatchAlarmMetric]]:
        """
        The metrics evaluated for the Alarm.
        """
        metrics = self.get("metrics")
        return [CloudWatchAlarmMetric(i) for i in metrics] if metrics else None

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop alarm_actions_suppressor : Optional[str]

Optional action suppression for the Alarm rule in case of composite alarm.

Expand source code
@property
def alarm_actions_suppressor(self) -> Optional[str]:
    """
    Optional action suppression for the Alarm rule in case of composite alarm.
    """
    return self.get("actionsSuppressor", None)
prop alarm_actions_suppressor_extension_period : Optional[str]

Optional action suppression extension period for the Alarm rule in case of composite alarm.

Expand source code
@property
def alarm_actions_suppressor_extension_period(self) -> Optional[str]:
    """
    Optional action suppression extension period for the Alarm rule in case of composite alarm.
    """
    return self.get("actionsSuppressorExtensionPeriod", None)
prop alarm_actions_suppressor_wait_period : Optional[str]

Optional action suppression wait period for the Alarm rule in case of composite alarm.

Expand source code
@property
def alarm_actions_suppressor_wait_period(self) -> Optional[str]:
    """
    Optional action suppression wait period for the Alarm rule in case of composite alarm.
    """
    return self.get("actionsSuppressorWaitPeriod", None)
prop alarm_rule : Optional[str]

Optional description for the Alarm rule in case of composite alarm.

Expand source code
@property
def alarm_rule(self) -> Optional[str]:
    """
    Optional description for the Alarm rule in case of composite alarm.
    """
    return self.get("alarmRule", None)
prop description : Optional[str]

Optional description for the Alarm.

Expand source code
@property
def description(self) -> Optional[str]:
    """
    Optional description for the Alarm.
    """
    return self.get("description", None)
prop metrics : Optional[List[CloudWatchAlarmMetric]]

The metrics evaluated for the Alarm.

Expand source code
@property
def metrics(self) -> Optional[List[CloudWatchAlarmMetric]]:
    """
    The metrics evaluated for the Alarm.
    """
    metrics = self.get("metrics")
    return [CloudWatchAlarmMetric(i) for i in metrics] if metrics else None

Inherited members

class CloudWatchAlarmData (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmData(DictWrapper):
    @property
    def alarm_name(self) -> str:
        """
        Alarm name.
        """
        return self["alarmName"]

    @property
    def state(self) -> CloudWatchAlarmState:
        """
        The current state of the Alarm.
        """
        return CloudWatchAlarmState(self["state"])

    @property
    def previous_state(self) -> CloudWatchAlarmState:
        """
        The previous state of the Alarm.
        """
        return CloudWatchAlarmState(self["previousState"])

    @property
    def configuration(self) -> CloudWatchAlarmConfiguration:
        """
        The configuration of the Alarm.
        """
        return CloudWatchAlarmConfiguration(self["configuration"])

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop alarm_name : str

Alarm name.

Expand source code
@property
def alarm_name(self) -> str:
    """
    Alarm name.
    """
    return self["alarmName"]
prop configurationCloudWatchAlarmConfiguration

The configuration of the Alarm.

Expand source code
@property
def configuration(self) -> CloudWatchAlarmConfiguration:
    """
    The configuration of the Alarm.
    """
    return CloudWatchAlarmConfiguration(self["configuration"])
prop previous_stateCloudWatchAlarmState

The previous state of the Alarm.

Expand source code
@property
def previous_state(self) -> CloudWatchAlarmState:
    """
    The previous state of the Alarm.
    """
    return CloudWatchAlarmState(self["previousState"])
prop stateCloudWatchAlarmState

The current state of the Alarm.

Expand source code
@property
def state(self) -> CloudWatchAlarmState:
    """
    The current state of the Alarm.
    """
    return CloudWatchAlarmState(self["state"])

Inherited members

class CloudWatchAlarmEvent (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmEvent(DictWrapper):
    @property
    def source(self) -> Literal["aws.cloudwatch"]:
        """
        Source of the triggered event.
        """
        return self["source"]

    @property
    def alarm_arn(self) -> str:
        """
        The ARN of the CloudWatch Alarm.
        """
        return self["alarmArn"]

    @property
    def region(self) -> str:
        """
        The AWS region in which the Alarm is active.
        """
        return self["region"]

    @property
    def source_account_id(self) -> str:
        """
        The AWS Account ID that the Alarm is deployed to.
        """
        return self["accountId"]

    @property
    def timestamp(self) -> str:
        """
        Alarm state change event timestamp in ISO-8601 format.
        """
        return self["time"]

    @property
    def alarm_data(self) -> CloudWatchAlarmData:
        """
        Contains basic data about the Alarm and its current and previous states.
        """
        return CloudWatchAlarmData(self["alarmData"])

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop alarm_arn : str

The ARN of the CloudWatch Alarm.

Expand source code
@property
def alarm_arn(self) -> str:
    """
    The ARN of the CloudWatch Alarm.
    """
    return self["alarmArn"]
prop alarm_dataCloudWatchAlarmData

Contains basic data about the Alarm and its current and previous states.

Expand source code
@property
def alarm_data(self) -> CloudWatchAlarmData:
    """
    Contains basic data about the Alarm and its current and previous states.
    """
    return CloudWatchAlarmData(self["alarmData"])
prop region : str

The AWS region in which the Alarm is active.

Expand source code
@property
def region(self) -> str:
    """
    The AWS region in which the Alarm is active.
    """
    return self["region"]
prop source : Literal['aws.cloudwatch']

Source of the triggered event.

Expand source code
@property
def source(self) -> Literal["aws.cloudwatch"]:
    """
    Source of the triggered event.
    """
    return self["source"]
prop source_account_id : str

The AWS Account ID that the Alarm is deployed to.

Expand source code
@property
def source_account_id(self) -> str:
    """
    The AWS Account ID that the Alarm is deployed to.
    """
    return self["accountId"]
prop timestamp : str

Alarm state change event timestamp in ISO-8601 format.

Expand source code
@property
def timestamp(self) -> str:
    """
    Alarm state change event timestamp in ISO-8601 format.
    """
    return self["time"]

Inherited members

class CloudWatchAlarmMetric (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmMetric(DictWrapper):
    @property
    def metric_id(self) -> str:
        """
        Unique ID of the alarm metric.
        """
        return self["id"]

    @property
    def expression(self) -> Optional[str]:
        """
        Optional expression of the alarm metric.
        """
        return self.get("expression", None)

    @property
    def label(self) -> Optional[str]:
        """
        Optional label of the alarm metric.
        """
        return self.get("label", None)

    @property
    def return_data(self) -> bool:
        """
        Whether this metric data is used to determine the state of the alarm or not.
        """
        return self["returnData"]

    @property
    def metric_stat(self) -> CloudWatchAlarmMetricStat:
        return CloudWatchAlarmMetricStat(self["metricStat"])

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop expression : Optional[str]

Optional expression of the alarm metric.

Expand source code
@property
def expression(self) -> Optional[str]:
    """
    Optional expression of the alarm metric.
    """
    return self.get("expression", None)
prop label : Optional[str]

Optional label of the alarm metric.

Expand source code
@property
def label(self) -> Optional[str]:
    """
    Optional label of the alarm metric.
    """
    return self.get("label", None)
prop metric_id : str

Unique ID of the alarm metric.

Expand source code
@property
def metric_id(self) -> str:
    """
    Unique ID of the alarm metric.
    """
    return self["id"]
prop metric_statCloudWatchAlarmMetricStat
Expand source code
@property
def metric_stat(self) -> CloudWatchAlarmMetricStat:
    return CloudWatchAlarmMetricStat(self["metricStat"])
prop return_data : bool

Whether this metric data is used to determine the state of the alarm or not.

Expand source code
@property
def return_data(self) -> bool:
    """
    Whether this metric data is used to determine the state of the alarm or not.
    """
    return self["returnData"]

Inherited members

class CloudWatchAlarmMetricStat (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmMetricStat(DictWrapper):
    @property
    def period(self) -> Optional[int]:
        """
        Metric evaluation period, in seconds.
        """
        return self.get("period", None)

    @property
    def stat(self) -> Optional[str]:
        """
        Statistical aggregation of metric points, e.g. Average, SampleCount, etc.
        """
        return self.get("stat", None)

    @property
    def unit(self) -> Optional[str]:
        """
        Unit for metric.
        """
        return self.get("unit", None)

    @property
    def metric(self) -> Optional[Dict]:
        """
        Metric details
        """
        return self.get("metric", {})

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop metric : Optional[Dict]

Metric details

Expand source code
@property
def metric(self) -> Optional[Dict]:
    """
    Metric details
    """
    return self.get("metric", {})
prop period : Optional[int]

Metric evaluation period, in seconds.

Expand source code
@property
def period(self) -> Optional[int]:
    """
    Metric evaluation period, in seconds.
    """
    return self.get("period", None)
prop stat : Optional[str]

Statistical aggregation of metric points, e.g. Average, SampleCount, etc.

Expand source code
@property
def stat(self) -> Optional[str]:
    """
    Statistical aggregation of metric points, e.g. Average, SampleCount, etc.
    """
    return self.get("stat", None)
prop unit : Optional[str]

Unit for metric.

Expand source code
@property
def unit(self) -> Optional[str]:
    """
    Unit for metric.
    """
    return self.get("unit", None)

Inherited members

class CloudWatchAlarmState (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchAlarmState(DictWrapper):
    @property
    def value(self) -> Literal["OK", "ALARM", "INSUFFICIENT_DATA"]:
        """
        Overall state of the alarm.
        """
        return self["value"]

    @property
    def reason(self) -> str:
        """
        Reason why alarm was changed to this state.
        """
        return self["reason"]

    @property
    def reason_data(self) -> str:
        """
        Additional data to back up the reason, usually contains the evaluated data points,
        the calculated threshold and timestamps.
        """
        return self["reasonData"]

    @cached_property
    def reason_data_decoded(self) -> Optional[Any]:
        """
        Deserialized version of reason_data.
        """

        return self._json_deserializer(self.reason_data) if self.reason_data else None

    @property
    def actions_suppressed_by(self) -> Optional[Literal["Alarm", "ExtensionPeriod", "WaitPeriod"]]:
        """
        Describes why the actions when the value is `ALARM` are suppressed in a composite
        alarm.
        """
        return self.get("actionsSuppressedBy", None)

    @property
    def actions_suppressed_reason(self) -> Optional[str]:
        """
        Captures the reason for action suppression.
        """
        return self.get("actionsSuppressedReason", None)

    @property
    def timestamp(self) -> str:
        """
        Timestamp of this state change in ISO-8601 format.
        """
        return self["timestamp"]

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop actions_suppressed_by : Optional[Literal['Alarm', 'ExtensionPeriod', 'WaitPeriod']]

Describes why the actions when the value is ALARM are suppressed in a composite alarm.

Expand source code
@property
def actions_suppressed_by(self) -> Optional[Literal["Alarm", "ExtensionPeriod", "WaitPeriod"]]:
    """
    Describes why the actions when the value is `ALARM` are suppressed in a composite
    alarm.
    """
    return self.get("actionsSuppressedBy", None)
prop actions_suppressed_reason : Optional[str]

Captures the reason for action suppression.

Expand source code
@property
def actions_suppressed_reason(self) -> Optional[str]:
    """
    Captures the reason for action suppression.
    """
    return self.get("actionsSuppressedReason", None)
prop reason : str

Reason why alarm was changed to this state.

Expand source code
@property
def reason(self) -> str:
    """
    Reason why alarm was changed to this state.
    """
    return self["reason"]
prop reason_data : str

Additional data to back up the reason, usually contains the evaluated data points, the calculated threshold and timestamps.

Expand source code
@property
def reason_data(self) -> str:
    """
    Additional data to back up the reason, usually contains the evaluated data points,
    the calculated threshold and timestamps.
    """
    return self["reasonData"]
var reason_data_decoded

Deserialized version of reason_data.

Expand source code
def __get__(self, instance, owner=None):
    if instance is None:
        return self
    if self.attrname is None:
        raise TypeError(
            "Cannot use cached_property instance without calling __set_name__ on it.")
    try:
        cache = instance.__dict__
    except AttributeError:  # not all objects have __dict__ (e.g. class defines slots)
        msg = (
            f"No '__dict__' attribute on {type(instance).__name__!r} "
            f"instance to cache {self.attrname!r} property."
        )
        raise TypeError(msg) from None
    val = cache.get(self.attrname, _NOT_FOUND)
    if val is _NOT_FOUND:
        val = self.func(instance)
        try:
            cache[self.attrname] = val
        except TypeError:
            msg = (
                f"The '__dict__' attribute on {type(instance).__name__!r} instance "
                f"does not support item assignment for caching {self.attrname!r} property."
            )
            raise TypeError(msg) from None
    return val
prop timestamp : str

Timestamp of this state change in ISO-8601 format.

Expand source code
@property
def timestamp(self) -> str:
    """
    Timestamp of this state change in ISO-8601 format.
    """
    return self["timestamp"]
prop value : Literal['OK', 'ALARM', 'INSUFFICIENT_DATA']

Overall state of the alarm.

Expand source code
@property
def value(self) -> Literal["OK", "ALARM", "INSUFFICIENT_DATA"]:
    """
    Overall state of the alarm.
    """
    return self["value"]

Inherited members