Module aws_lambda_powertools.utilities.data_classes.cloud_watch_alarm_event

Classes

class CloudWatchAlarmConfiguration (data: dict[str, Any], json_deserializer: Callable | None = 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) -> str | None:
        """
        Optional description for the Alarm.
        """
        return self.get("description", None)

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

    @property
    def alarm_actions_suppressor(self) -> str | None:
        """
        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) -> str | None:
        """
        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) -> str | None:
        """
        Optional action suppression extension period for the Alarm rule in case of composite alarm.
        """
        return self.get("actionsSuppressorExtensionPeriod", None)

    @property
    def metrics(self) -> list[CloudWatchAlarmMetric]:
        """
        The metrics evaluated for the Alarm.
        """
        metrics = self.get("metrics") or []
        return [CloudWatchAlarmMetric(i) for i in metrics]

Ancestors

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

Instance variables

prop alarm_actions_suppressor : str | None

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

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

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) -> str | None:
    """
    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 : str | None

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) -> str | None:
    """
    Optional action suppression wait period for the Alarm rule in case of composite alarm.
    """
    return self.get("actionsSuppressorWaitPeriod", None)
prop alarm_rule : str | None

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

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

Optional description for the Alarm.

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

The metrics evaluated for the Alarm.

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

Inherited members

class CloudWatchAlarmData (data: dict[str, Any], json_deserializer: Callable | None = 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
  • typing.Generic

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: Callable | None = 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
  • typing.Generic

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: Callable | None = 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) -> str | None:
        """
        Optional expression of the alarm metric.
        """
        return self.get("expression", None)

    @property
    def label(self) -> str | None:
        """
        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
  • typing.Generic

Instance variables

prop expression : str | None

Optional expression of the alarm metric.

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

Optional label of the alarm metric.

Expand source code
@property
def label(self) -> str | None:
    """
    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: Callable | None = 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) -> int | None:
        """
        Metric evaluation period, in seconds.
        """
        return self.get("period", None)

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

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

    @property
    def metric(self) -> dict:
        """
        Metric details
        """
        return self.get("metric") or {}

Ancestors

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

Instance variables

prop metric : dict

Metric details

Expand source code
@property
def metric(self) -> dict:
    """
    Metric details
    """
    return self.get("metric") or {}
prop period : int | None

Metric evaluation period, in seconds.

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

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

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

Unit for metric.

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

Inherited members

class CloudWatchAlarmState (data: dict[str, Any], json_deserializer: Callable | None = 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) -> Any | None:
        """
        Deserialized version of reason_data.
        """

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

    @property
    def actions_suppressed_by(self) -> Literal["Alarm", "ExtensionPeriod", "WaitPeriod"] | None:
        """
        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) -> str | None:
        """
        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
  • typing.Generic

Instance variables

prop actions_suppressed_by : Literal['Alarm', 'ExtensionPeriod', 'WaitPeriod'] | None

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

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

Captures the reason for action suppression.

Expand source code
@property
def actions_suppressed_reason(self) -> str | None:
    """
    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