Skip to content

describe_alarms

describe_alarms(
    *,
    config_overrides: Optional[CloudWatchClientConfig] = None,
    alarm_names: Optional[AlarmNames] = None,
    alarm_name_prefix: Optional[AlarmNamePrefix] = None,
    alarm_types: Optional[AlarmTypes] = None,
    children_of_alarm_name: Optional[AlarmName] = None,
    parents_of_alarm_name: Optional[AlarmName] = None,
    state_value: Optional[StateValue] = None,
    action_prefix: Optional[ActionPrefix] = None,
    max_records: Optional[MaxRecords] = None,
    next_token: Optional[NextToken] = None,
) -> DescribeAlarmsOutput

Retrieves the specified alarms. You can filter the results by specifying a prefix for the alarm name, the alarm state, or a prefix for any action.

To use this operation and return information about composite alarms, you must be signed on with the cloudwatch:DescribeAlarms permission that is scoped to *. You can't return information about composite alarms if your cloudwatch:DescribeAlarms permission has a narrower scope.

Parameters:

  • alarm_names (Optional[AlarmNames], default: None ) –

    The names of the alarms to retrieve information about.

  • alarm_name_prefix (Optional[AlarmNamePrefix], default: None ) –

    An alarm name prefix. If you specify this parameter, you receive information about all alarms that have names that start with this prefix.

    If this parameter is specified, you cannot specify AlarmNames.

  • alarm_types (Optional[AlarmTypes], default: None ) –

    Use this parameter to specify whether you want the operation to return metric alarms, composite alarms, or log alarms. If you omit this parameter, only metric alarms are returned, even if composite alarms or log alarms exist in the account.

    For example, if you omit this parameter or specify MetricAlarms, the operation returns only a list of metric alarms. It does not return any composite alarms or log alarms, even if they exist in the account.

    If you specify CompositeAlarms, the operation returns only a list of composite alarms, and does not return any metric alarms or log alarms.

    If you specify LogAlarms, the operation returns only a list of log alarms, and does not return any metric alarms or composite alarms.

  • children_of_alarm_name (Optional[AlarmName], default: None ) –

    If you use this parameter and specify the name of a composite alarm, the operation returns information about the "children" alarms of the alarm you specify. These are the metric alarms and composite alarms referenced in the AlarmRule field of the composite alarm that you specify in ChildrenOfAlarmName. Information about the composite alarm that you name in ChildrenOfAlarmName is not returned.

    If you specify ChildrenOfAlarmName, you cannot specify any other parameters in the request except for MaxRecords and NextToken. If you do so, you receive a validation error.

    Only the Alarm Name, ARN, StateValue (OK/ALARM/INSUFFICIENT_DATA), and StateUpdatedTimestamp information are returned by this operation when you use this parameter. To get complete information about these alarms, perform another DescribeAlarms operation and specify the parent alarm names in the AlarmNames parameter.

  • parents_of_alarm_name (Optional[AlarmName], default: None ) –

    If you use this parameter and specify the name of a metric or composite alarm, the operation returns information about the "parent" alarms of the alarm you specify. These are the composite alarms that have AlarmRule parameters that reference the alarm named in ParentsOfAlarmName. Information about the alarm that you specify in ParentsOfAlarmName is not returned.

    If you specify ParentsOfAlarmName, you cannot specify any other parameters in the request except for MaxRecords and NextToken. If you do so, you receive a validation error.

    Only the Alarm Name and ARN are returned by this operation when you use this parameter. To get complete information about these alarms, perform another DescribeAlarms operation and specify the parent alarm names in the AlarmNames parameter.

  • state_value (Optional[StateValue], default: None ) –

    Specify this parameter to receive information only about alarms that are currently in the state that you specify.

  • action_prefix (Optional[ActionPrefix], default: None ) –

    Use this parameter to filter the results of the operation to only those alarms that use a certain alarm action. For example, you could specify the ARN of an SNS topic to find all alarms that send notifications to that topic.

  • max_records (Optional[MaxRecords], default: None ) –

    The maximum number of alarm descriptions to retrieve.

  • next_token (Optional[NextToken], default: None ) –

    The token returned by a previous call to indicate that there is more data available.

Raises:

Source code in docs_src/capo_cloudwatch/_services/cloud_watch.py
def describe_alarms(
    self,
    *,
    config_overrides: Optional[CloudWatchClientConfig] = None,
    alarm_names: Optional["capo_cloudwatch.types.alarm_names.AlarmNames"] = None,
    alarm_name_prefix: Optional[
        "capo_cloudwatch.types.alarm_name_prefix.AlarmNamePrefix"
    ] = None,
    alarm_types: Optional["capo_cloudwatch.types.alarm_types.AlarmTypes"] = None,
    children_of_alarm_name: Optional[
        "capo_cloudwatch.types.alarm_name.AlarmName"
    ] = None,
    parents_of_alarm_name: Optional[
        "capo_cloudwatch.types.alarm_name.AlarmName"
    ] = None,
    state_value: Optional["capo_cloudwatch.types.state_value.StateValue"] = None,
    action_prefix: Optional[
        "capo_cloudwatch.types.action_prefix.ActionPrefix"
    ] = None,
    max_records: Optional["capo_cloudwatch.types.max_records.MaxRecords"] = None,
    next_token: Optional["capo_cloudwatch.types.next_token.NextToken"] = None,
) -> "capo_cloudwatch.types.describe_alarms_output.DescribeAlarmsOutput":
    """<p>Retrieves the specified alarms. You can filter the results by specifying a prefix for the alarm name, the alarm state, or a prefix for any action.</p> <p>To use this operation and return information about composite alarms, you must be signed on with the <code>cloudwatch:DescribeAlarms</code> permission that is scoped to <code>*</code>. You can't return information about composite alarms if your <code>cloudwatch:DescribeAlarms</code> permission has a narrower scope.</p>

    Args:
        alarm_names: <p>The names of the alarms to retrieve information about.</p>
        alarm_name_prefix: <p>An alarm name prefix. If you specify this parameter, you receive information about all alarms that have names that start with this prefix.</p> <p>If this parameter is specified, you cannot specify <code>AlarmNames</code>.</p>
        alarm_types: <p>Use this parameter to specify whether you want the operation to return metric alarms, composite alarms, or log alarms. If you omit this parameter, only metric alarms are returned, even if composite alarms or log alarms exist in the account.</p> <p>For example, if you omit this parameter or specify <code>MetricAlarms</code>, the operation returns only a list of metric alarms. It does not return any composite alarms or log alarms, even if they exist in the account.</p> <p>If you specify <code>CompositeAlarms</code>, the operation returns only a list of composite alarms, and does not return any metric alarms or log alarms.</p> <p>If you specify <code>LogAlarms</code>, the operation returns only a list of log alarms, and does not return any metric alarms or composite alarms.</p>
        children_of_alarm_name: <p>If you use this parameter and specify the name of a composite alarm, the operation returns information about the "children" alarms of the alarm you specify. These are the metric alarms and composite alarms referenced in the <code>AlarmRule</code> field of the composite alarm that you specify in <code>ChildrenOfAlarmName</code>. Information about the composite alarm that you name in <code>ChildrenOfAlarmName</code> is not returned.</p> <p>If you specify <code>ChildrenOfAlarmName</code>, you cannot specify any other parameters in the request except for <code>MaxRecords</code> and <code>NextToken</code>. If you do so, you receive a validation error.</p> <note> <p>Only the <code>Alarm Name</code>, <code>ARN</code>, <code>StateValue</code> (OK/ALARM/INSUFFICIENT_DATA), and <code>StateUpdatedTimestamp</code> information are returned by this operation when you use this parameter. To get complete information about these alarms, perform another <code>DescribeAlarms</code> operation and specify the parent alarm names in the <code>AlarmNames</code> parameter.</p> </note>
        parents_of_alarm_name: <p>If you use this parameter and specify the name of a metric or composite alarm, the operation returns information about the "parent" alarms of the alarm you specify. These are the composite alarms that have <code>AlarmRule</code> parameters that reference the alarm named in <code>ParentsOfAlarmName</code>. Information about the alarm that you specify in <code>ParentsOfAlarmName</code> is not returned.</p> <p>If you specify <code>ParentsOfAlarmName</code>, you cannot specify any other parameters in the request except for <code>MaxRecords</code> and <code>NextToken</code>. If you do so, you receive a validation error.</p> <note> <p>Only the Alarm Name and ARN are returned by this operation when you use this parameter. To get complete information about these alarms, perform another <code>DescribeAlarms</code> operation and specify the parent alarm names in the <code>AlarmNames</code> parameter.</p> </note>
        state_value: <p>Specify this parameter to receive information only about alarms that are currently in the state that you specify.</p>
        action_prefix: <p>Use this parameter to filter the results of the operation to only those alarms that use a certain alarm action. For example, you could specify the ARN of an SNS topic to find all alarms that send notifications to that topic.</p>
        max_records: <p>The maximum number of alarm descriptions to retrieve.</p>
        next_token: <p>The token returned by a previous call to indicate that there is more data available.</p>

    Raises:
        capo_cloudwatch.errors.invalid_next_token.InvalidNextToken: <p>The next token specified is invalid.</p>
        capo_cloudwatch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch.types.describe_alarms_input.DescribeAlarmsInput]",
    ) -> OperationResponse[
        "capo_cloudwatch.types.describe_alarms_output.DescribeAlarmsOutput"
    ]:
        import capo_cloudwatch._operations.granite_service_version20100801.describe_alarms

        output, http_response = (
            capo_cloudwatch._operations.granite_service_version20100801.describe_alarms.describe_alarms(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeAlarms")
    )
    input_: capo_cloudwatch.types.describe_alarms_input.DescribeAlarmsInput = {}
    if alarm_names is not None:
        input_["alarm_names"] = alarm_names
    if alarm_name_prefix is not None:
        input_["alarm_name_prefix"] = alarm_name_prefix
    if alarm_types is not None:
        input_["alarm_types"] = alarm_types
    if children_of_alarm_name is not None:
        input_["children_of_alarm_name"] = children_of_alarm_name
    if parents_of_alarm_name is not None:
        input_["parents_of_alarm_name"] = parents_of_alarm_name
    if state_value is not None:
        input_["state_value"] = state_value
    if action_prefix is not None:
        input_["action_prefix"] = action_prefix
    if max_records is not None:
        input_["max_records"] = max_records
    if next_token is not None:
        input_["next_token"] = next_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output