Jump to Content

New API Documentation - Developer Preview Available

We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.

Class ListMetricsCommandProtected

List the specified metrics. You can use the returned metrics with GetMetricData or GetMetricStatistics to get statistical data.

Up to 500 results are returned for any one call. To retrieve additional results, use the returned token with subsequent calls.

After you create a metric, allow up to 15 minutes for the metric to appear. To see metric statistics sooner, use GetMetricData or GetMetricStatistics.

If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account and view metrics from the linked source accounts. For more information, see CloudWatch cross-account observability.

ListMetrics doesn't return information about metrics if those metrics haven't reported data in the past two weeks. To retrieve those metrics, use GetMetricData or GetMetricStatistics.

Example

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

import { CloudWatchClient, ListMetricsCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
// const { CloudWatchClient, ListMetricsCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
const client = new CloudWatchClient(config);
const input = { // ListMetricsInput
Namespace: "STRING_VALUE",
MetricName: "STRING_VALUE",
Dimensions: [ // DimensionFilters
{ // DimensionFilter
Name: "STRING_VALUE", // required
Value: "STRING_VALUE",
},
],
NextToken: "STRING_VALUE",
RecentlyActive: "PT3H",
IncludeLinkedAccounts: true || false,
OwningAccount: "STRING_VALUE",
};
const command = new ListMetricsCommand(input);
const response = await client.send(command);
// { // ListMetricsOutput
// Metrics: [ // Metrics
// { // Metric
// Namespace: "STRING_VALUE",
// MetricName: "STRING_VALUE",
// Dimensions: [ // Dimensions
// { // Dimension
// Name: "STRING_VALUE", // required
// Value: "STRING_VALUE", // required
// },
// ],
// },
// ],
// NextToken: "STRING_VALUE",
// OwningAccounts: [ // OwningAccounts
// "STRING_VALUE",
// ],
// };

Param

ListMetricsCommandInput

Returns

ListMetricsCommandOutput

See

Throws

InternalServiceFault (server fault)

Request processing has failed due to some unknown error, exception, or failure.

Throws

InvalidParameterValueException (client fault)

The value of an input parameter is bad or out-of-range.

Throws

CloudWatchServiceException

Base exception class for all service exceptions from CloudWatch service.

Hierarchy

Constructors

Properties

middlewareStack: MiddlewareStack<ListMetricsCommandInput, ListMetricsCommandOutput>

Methods