- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
DescribeAlarmsCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CloudWatchClient, DescribeAlarmsCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
// const { CloudWatchClient, DescribeAlarmsCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
const client = new CloudWatchClient(config);
const input = { // DescribeAlarmsInput
AlarmNames: [ // AlarmNames
"STRING_VALUE",
],
AlarmNamePrefix: "STRING_VALUE",
AlarmTypes: [ // AlarmTypes
"CompositeAlarm" || "MetricAlarm",
],
ChildrenOfAlarmName: "STRING_VALUE",
ParentsOfAlarmName: "STRING_VALUE",
StateValue: "OK" || "ALARM" || "INSUFFICIENT_DATA",
ActionPrefix: "STRING_VALUE",
MaxRecords: Number("int"),
NextToken: "STRING_VALUE",
};
const command = new DescribeAlarmsCommand(input);
const response = await client.send(command);
// { // DescribeAlarmsOutput
// CompositeAlarms: [ // CompositeAlarms
// { // CompositeAlarm
// ActionsEnabled: true || false,
// AlarmActions: [ // ResourceList
// "STRING_VALUE",
// ],
// AlarmArn: "STRING_VALUE",
// AlarmConfigurationUpdatedTimestamp: new Date("TIMESTAMP"),
// AlarmDescription: "STRING_VALUE",
// AlarmName: "STRING_VALUE",
// AlarmRule: "STRING_VALUE",
// InsufficientDataActions: [
// "STRING_VALUE",
// ],
// OKActions: [
// "STRING_VALUE",
// ],
// StateReason: "STRING_VALUE",
// StateReasonData: "STRING_VALUE",
// StateUpdatedTimestamp: new Date("TIMESTAMP"),
// StateValue: "OK" || "ALARM" || "INSUFFICIENT_DATA",
// StateTransitionedTimestamp: new Date("TIMESTAMP"),
// ActionsSuppressedBy: "WaitPeriod" || "ExtensionPeriod" || "Alarm",
// ActionsSuppressedReason: "STRING_VALUE",
// ActionsSuppressor: "STRING_VALUE",
// ActionsSuppressorWaitPeriod: Number("int"),
// ActionsSuppressorExtensionPeriod: Number("int"),
// },
// ],
// MetricAlarms: [ // MetricAlarms
// { // MetricAlarm
// AlarmName: "STRING_VALUE",
// AlarmArn: "STRING_VALUE",
// AlarmDescription: "STRING_VALUE",
// AlarmConfigurationUpdatedTimestamp: new Date("TIMESTAMP"),
// ActionsEnabled: true || false,
// OKActions: [
// "STRING_VALUE",
// ],
// AlarmActions: [
// "STRING_VALUE",
// ],
// InsufficientDataActions: "<ResourceList>",
// StateValue: "OK" || "ALARM" || "INSUFFICIENT_DATA",
// StateReason: "STRING_VALUE",
// StateReasonData: "STRING_VALUE",
// StateUpdatedTimestamp: new Date("TIMESTAMP"),
// MetricName: "STRING_VALUE",
// Namespace: "STRING_VALUE",
// Statistic: "SampleCount" || "Average" || "Sum" || "Minimum" || "Maximum",
// ExtendedStatistic: "STRING_VALUE",
// Dimensions: [ // Dimensions
// { // Dimension
// Name: "STRING_VALUE", // required
// Value: "STRING_VALUE", // required
// },
// ],
// Period: Number("int"),
// Unit: "Seconds" || "Microseconds" || "Milliseconds" || "Bytes" || "Kilobytes" || "Megabytes" || "Gigabytes" || "Terabytes" || "Bits" || "Kilobits" || "Megabits" || "Gigabits" || "Terabits" || "Percent" || "Count" || "Bytes/Second" || "Kilobytes/Second" || "Megabytes/Second" || "Gigabytes/Second" || "Terabytes/Second" || "Bits/Second" || "Kilobits/Second" || "Megabits/Second" || "Gigabits/Second" || "Terabits/Second" || "Count/Second" || "None",
// EvaluationPeriods: Number("int"),
// DatapointsToAlarm: Number("int"),
// Threshold: Number("double"),
// ComparisonOperator: "GreaterThanOrEqualToThreshold" || "GreaterThanThreshold" || "LessThanThreshold" || "LessThanOrEqualToThreshold" || "LessThanLowerOrGreaterThanUpperThreshold" || "LessThanLowerThreshold" || "GreaterThanUpperThreshold",
// TreatMissingData: "STRING_VALUE",
// EvaluateLowSampleCountPercentile: "STRING_VALUE",
// Metrics: [ // MetricDataQueries
// { // MetricDataQuery
// Id: "STRING_VALUE", // required
// MetricStat: { // MetricStat
// Metric: { // Metric
// Namespace: "STRING_VALUE",
// MetricName: "STRING_VALUE",
// Dimensions: [
// {
// Name: "STRING_VALUE", // required
// Value: "STRING_VALUE", // required
// },
// ],
// },
// Period: Number("int"), // required
// Stat: "STRING_VALUE", // required
// Unit: "Seconds" || "Microseconds" || "Milliseconds" || "Bytes" || "Kilobytes" || "Megabytes" || "Gigabytes" || "Terabytes" || "Bits" || "Kilobits" || "Megabits" || "Gigabits" || "Terabits" || "Percent" || "Count" || "Bytes/Second" || "Kilobytes/Second" || "Megabytes/Second" || "Gigabytes/Second" || "Terabytes/Second" || "Bits/Second" || "Kilobits/Second" || "Megabits/Second" || "Gigabits/Second" || "Terabits/Second" || "Count/Second" || "None",
// },
// Expression: "STRING_VALUE",
// Label: "STRING_VALUE",
// ReturnData: true || false,
// Period: Number("int"),
// AccountId: "STRING_VALUE",
// },
// ],
// ThresholdMetricId: "STRING_VALUE",
// EvaluationState: "PARTIAL_DATA",
// StateTransitionedTimestamp: new Date("TIMESTAMP"),
// },
// ],
// NextToken: "STRING_VALUE",
// };
DescribeAlarmsCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
ActionPrefix | string | undefined | 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. |
AlarmNamePrefix | string | undefined | 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 | string[] | undefined | The names of the alarms to retrieve information about. |
AlarmTypes | AlarmType[] | undefined | Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If you omit this parameter, only metric alarms are returned, even if composite alarms exist in the account. For example, if you omit this parameter or specify If you specify |
ChildrenOfAlarmName | string | undefined | 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 If you specify Only the |
MaxRecords | number | undefined | The maximum number of alarm descriptions to retrieve. |
NextToken | string | undefined | The token returned by a previous call to indicate that there is more data available. |
ParentsOfAlarmName | string | undefined | 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 If you specify 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 |
StateValue | StateValue | undefined | Specify this parameter to receive information only about alarms that are currently in the state that you specify. |
DescribeAlarmsCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
CompositeAlarms | CompositeAlarm[] | undefined | The information about any composite alarms returned by the operation. |
MetricAlarms | MetricAlarm[] | undefined | The information about any metric alarms returned by the operation. |
NextToken | string | undefined | The token that marks the start of the next batch of returned results. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InvalidNextToken | client | The next token specified is invalid. |
CloudWatchServiceException | Base exception class for all service exceptions from CloudWatch service. |