DescribeAlarmsForMetricCommand

Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.

This operation retrieves only standard alarms that are based on the specified metric. It does not return alarms based on math expressions that use the specified metric, or composite alarms that use the specified metric.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CloudWatchClient, DescribeAlarmsForMetricCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
// const { CloudWatchClient, DescribeAlarmsForMetricCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
const client = new CloudWatchClient(config);
const input = { // DescribeAlarmsForMetricInput
  MetricName: "STRING_VALUE", // required
  Namespace: "STRING_VALUE", // required
  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",
};
const command = new DescribeAlarmsForMetricCommand(input);
const response = await client.send(command);
// { // DescribeAlarmsForMetricOutput
//   MetricAlarms: [ // MetricAlarms
//     { // MetricAlarm
//       AlarmName: "STRING_VALUE",
//       AlarmArn: "STRING_VALUE",
//       AlarmDescription: "STRING_VALUE",
//       AlarmConfigurationUpdatedTimestamp: new Date("TIMESTAMP"),
//       ActionsEnabled: true || false,
//       OKActions: [ // ResourceList
//         "STRING_VALUE",
//       ],
//       AlarmActions: [
//         "STRING_VALUE",
//       ],
//       InsufficientDataActions: [
//         "STRING_VALUE",
//       ],
//       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"),
//     },
//   ],
// };

DescribeAlarmsForMetricCommand Input

Parameter
Type
Description
MetricName
Required
string | undefined

The name of the metric.

Namespace
Required
string | undefined

The namespace of the metric.

Dimensions
Dimension[] | undefined

The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them in order for the call to succeed.

ExtendedStatistic
string | undefined

The percentile statistic for the metric. Specify a value between p0.0 and p100.

Period
number | undefined

The period, in seconds, over which the statistic is applied.

Statistic
Statistic | undefined

The statistic for the metric, other than percentiles. For percentile statistics, use ExtendedStatistics.

Unit
StandardUnit | undefined

The unit for the metric.

DescribeAlarmsForMetricCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
MetricAlarms
MetricAlarm[] | undefined

The information for each alarm with the specified metric.

Throws

Name
Fault
Details
CloudWatchServiceException
Base exception class for all service exceptions from CloudWatch service.