CloudWatch class
Amazon CloudWatch monitors your Amazon Web Services (Amazon Web Services) resources and the applications you run on Amazon Web Services in real time. You can use CloudWatch to collect and track metrics, which are the variables you want to measure for your resources and applications.
CloudWatch alarms send notifications or automatically change the resources you are monitoring based on rules that you define. For example, you can monitor the CPU usage and disk reads and writes of your Amazon EC2 instances. Then, use this data to determine whether you should launch additional instances to handle increased load. You can also use this data to stop under-used instances to save money.
In addition to monitoring the built-in metrics that come with Amazon Web Services, you can monitor your own custom metrics. With CloudWatch, you gain system-wide visibility into resource utilization, application performance, and operational health.
Constructors
- CloudWatch({required String region, AwsClientCredentials? credentials, AwsClientCredentialsProvider? credentialsProvider, Client? client, String? endpointUrl})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Closes the internal HTTP client if none was provided at creation. If a client was passed as a constructor argument, this becomes a noop.
-
deleteAlarmMuteRule(
{required String alarmMuteRuleName}) → Future< void> - Deletes a specific alarm mute rule.
-
deleteAlarms(
{required List< String> alarmNames}) → Future<void> - Deletes the specified alarms. You can delete up to 100 alarms in one operation. However, this total can include no more than one composite alarm. For example, you could delete 99 metric alarms and one composite alarms with one operation, but you can't delete two composite alarms with one operation.
-
deleteAnomalyDetector(
{List< Dimension> ? dimensions, MetricMathAnomalyDetector? metricMathAnomalyDetector, String? metricName, String? namespace, SingleMetricAnomalyDetector? singleMetricAnomalyDetector, String? stat}) → Future<void> - Deletes the specified anomaly detection model from your account. For more information about how to delete an anomaly detection model, see Deleting an anomaly detection model in the CloudWatch User Guide.
-
deleteDashboards(
{required List< String> dashboardNames}) → Future<void> - Deletes all dashboards that you specify. You can specify up to 100 dashboards to delete. If there is an error during this call, the operation attempts to delete as many dashboards as possible.
-
deleteInsightRules(
{required List< String> ruleNames}) → Future<DeleteInsightRulesOutput> - Permanently deletes the specified Contributor Insights rules.
-
deleteMetricStream(
{required String name}) → Future< void> - Permanently deletes the metric stream that you specify.
-
describeAlarmContributors(
{required String alarmName, String? nextToken}) → Future< DescribeAlarmContributorsOutput> -
Returns the information of the current alarm contributors that are in
ALARMstate. This operation returns details about the individual time series that contribute to the alarm's state. -
describeAlarmHistory(
{String? alarmContributorId, String? alarmName, List< AlarmType> ? alarmTypes, DateTime? endDate, HistoryItemType? historyItemType, int? maxRecords, String? nextToken, ScanBy? scanBy, DateTime? startDate}) → Future<DescribeAlarmHistoryOutput> - Retrieves the history for the specified alarm. You can filter the results by date range or item type. If an alarm name is not specified, the histories for either all metric alarms or all composite alarms are returned.
-
describeAlarms(
{String? actionPrefix, String? alarmNamePrefix, List< String> ? alarmNames, List<AlarmType> ? alarmTypes, String? childrenOfAlarmName, int? maxRecords, String? nextToken, String? parentsOfAlarmName, StateValue? stateValue}) → Future<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.
-
describeAlarmsForMetric(
{required String metricName, required String namespace, List< Dimension> ? dimensions, String? extendedStatistic, int? period, Statistic? statistic, StandardUnit? unit}) → Future<DescribeAlarmsForMetricOutput> - Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.
-
describeAnomalyDetectors(
{List< AnomalyDetectorType> ? anomalyDetectorTypes, List<Dimension> ? dimensions, int? maxResults, String? metricName, String? namespace, String? nextToken}) → Future<DescribeAnomalyDetectorsOutput> -
Lists the anomaly detection models that you have created in your account.
For single metric anomaly detectors, you can list all of the models in
your account or filter the results to only the models that are related to
a certain namespace, metric name, or metric dimension. For metric math
anomaly detectors, you can list them by adding
METRIC_MATHto theAnomalyDetectorTypesarray. This will return all metric math anomaly detectors in your account. -
describeInsightRules(
{int? maxResults, String? nextToken}) → Future< DescribeInsightRulesOutput> - Returns a list of all the Contributor Insights rules in your account.
-
disableAlarmActions(
{required List< String> alarmNames}) → Future<void> - Disables the actions for the specified alarms. When an alarm's actions are disabled, the alarm actions do not execute when the alarm state changes.
-
disableInsightRules(
{required List< String> ruleNames}) → Future<DisableInsightRulesOutput> - Disables the specified Contributor Insights rules. When rules are disabled, they do not analyze log groups and do not incur costs.
-
enableAlarmActions(
{required List< String> alarmNames}) → Future<void> - Enables the actions for the specified alarms.
-
enableInsightRules(
{required List< String> ruleNames}) → Future<EnableInsightRulesOutput> - Enables the specified Contributor Insights rules. When rules are enabled, they immediately begin analyzing log data.
-
getAlarmMuteRule(
{required String alarmMuteRuleName}) → Future< GetAlarmMuteRuleOutput> - Retrieves details for a specific alarm mute rule.
-
getDashboard(
{required String dashboardName}) → Future< GetDashboardOutput> - Displays the details of the dashboard that you specify.
-
getInsightRuleReport(
{required DateTime endTime, required int period, required String ruleName, required DateTime startTime, int? maxContributorCount, List< String> ? metrics, String? orderBy}) → Future<GetInsightRuleReportOutput> - This operation returns the time series data collected by a Contributor Insights rule. The data includes the identity and number of contributors to the log group.
-
getMetricData(
{required DateTime endTime, required List< MetricDataQuery> metricDataQueries, required DateTime startTime, LabelOptions? labelOptions, int? maxDatapoints, String? nextToken, ScanBy? scanBy}) → Future<GetMetricDataOutput> -
You can use the
GetMetricDataAPI to retrieve CloudWatch metric values. The operation can also include a CloudWatch Metrics Insights query, and one or more metric math functions. -
getMetricStatistics(
{required DateTime endTime, required String metricName, required String namespace, required int period, required DateTime startTime, List< Dimension> ? dimensions, List<String> ? extendedStatistics, List<Statistic> ? statistics, StandardUnit? unit}) → Future<GetMetricStatisticsOutput> - Gets statistics for the specified metric.
-
getMetricStream(
{required String name}) → Future< GetMetricStreamOutput> - Returns information about the metric stream that you specify.
-
getMetricWidgetImage(
{required String metricWidget, String? outputFormat}) → Future< GetMetricWidgetImageOutput> -
You can use the
GetMetricWidgetImageAPI to retrieve a snapshot graph of one or more Amazon CloudWatch metrics as a bitmap image. You can then embed this image into your services and products, such as wiki pages, reports, and documents. You could also retrieve images regularly, such as every minute, and create your own custom live dashboard. -
getOTelEnrichment(
) → Future< GetOTelEnrichmentOutput> - Returns the current status of vended metric enrichment for the account, including whether CloudWatch vended metrics are enriched with resource ARN and resource tag labels and queryable using PromQL. For the list of supported resources, see Supported Amazon Web Services infrastructure metrics.
-
listAlarmMuteRules(
{String? alarmName, int? maxRecords, String? nextToken, List< AlarmMuteRuleStatus> ? statuses}) → Future<ListAlarmMuteRulesOutput> - Lists alarm mute rules in your Amazon Web Services account and region.
-
listDashboards(
{String? dashboardNamePrefix, String? nextToken}) → Future< ListDashboardsOutput> -
Returns a list of the dashboards for your account. If you include
DashboardNamePrefix, only those dashboards with names starting with the prefix are listed. Otherwise, all dashboards in your account are listed. -
listManagedInsightRules(
{required String resourceARN, int? maxResults, String? nextToken}) → Future< ListManagedInsightRulesOutput> - Returns a list that contains the number of managed Contributor Insights rules in your account.
-
listMetrics(
{List< DimensionFilter> ? dimensions, bool? includeLinkedAccounts, String? metricName, String? namespace, String? nextToken, String? owningAccount, RecentlyActive? recentlyActive}) → Future<ListMetricsOutput> - List the specified metrics. You can use the returned metrics with GetMetricData or GetMetricStatistics to get statistical data.
-
listMetricStreams(
{int? maxResults, String? nextToken}) → Future< ListMetricStreamsOutput> - Returns a list of metric streams in this account.
-
listTagsForResource(
{required String resourceARN}) → Future< ListTagsForResourceOutput> - Displays the tags associated with a CloudWatch resource. Currently, alarms, dashboards, metric streams and Contributor Insights rules support tagging.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
putAlarmMuteRule(
{required String name, required Rule rule, String? description, DateTime? expireDate, MuteTargets? muteTargets, DateTime? startDate, List< Tag> ? tags}) → Future<void> - Creates or updates an alarm mute rule.
-
putAnomalyDetector(
{AnomalyDetectorConfiguration? configuration, List< Dimension> ? dimensions, MetricCharacteristics? metricCharacteristics, MetricMathAnomalyDetector? metricMathAnomalyDetector, String? metricName, String? namespace, SingleMetricAnomalyDetector? singleMetricAnomalyDetector, String? stat}) → Future<void> - Creates an anomaly detection model for a CloudWatch metric. You can use the model to display a band of expected normal values when the metric is graphed.
-
putCompositeAlarm(
{required String alarmName, required String alarmRule, bool? actionsEnabled, String? actionsSuppressor, int? actionsSuppressorExtensionPeriod, int? actionsSuppressorWaitPeriod, List< String> ? alarmActions, String? alarmDescription, List<String> ? insufficientDataActions, List<String> ? oKActions, List<Tag> ? tags}) → Future<void> - Creates or updates a composite alarm. When you create a composite alarm, you specify a rule expression for the alarm that takes into account the alarm states of other alarms that you have created. The composite alarm goes into ALARM state only if all conditions of the rule are met.
-
putDashboard(
{required String dashboardBody, required String dashboardName, List< Tag> ? tags}) → Future<PutDashboardOutput> - Creates a dashboard if it does not already exist, or updates an existing dashboard. If you update a dashboard, the entire contents are replaced with what you specify here.
-
putInsightRule(
{required String ruleDefinition, required String ruleName, bool? applyOnTransformedLogs, String? ruleState, List< Tag> ? tags}) → Future<void> - Creates a Contributor Insights rule. Rules evaluate log events in a CloudWatch Logs log group, enabling you to find contributor data for the log events in that log group. For more information, see Using Contributor Insights to Analyze High-Cardinality Data.
-
putManagedInsightRules(
{required List< ManagedRule> managedRules}) → Future<PutManagedInsightRulesOutput> -
Creates a managed Contributor Insights rule for a specified Amazon Web
Services resource. When you enable a managed rule, you create a
Contributor Insights rule that collects data from Amazon Web Services
services. You cannot edit these rules with
PutInsightRule. The rules can be enabled, disabled, and deleted usingEnableInsightRules,DisableInsightRules, andDeleteInsightRules. If a previously created managed rule is currently disabled, a subsequent call to this API will re-enable it. UseListManagedInsightRulesto describe all available rules. -
putMetricAlarm(
{required String alarmName, bool? actionsEnabled, List< String> ? alarmActions, String? alarmDescription, ComparisonOperator? comparisonOperator, int? datapointsToAlarm, List<Dimension> ? dimensions, String? evaluateLowSampleCountPercentile, EvaluationCriteria? evaluationCriteria, int? evaluationInterval, int? evaluationPeriods, String? extendedStatistic, List<String> ? insufficientDataActions, String? metricName, List<MetricDataQuery> ? metrics, String? namespace, List<String> ? oKActions, int? period, Statistic? statistic, List<Tag> ? tags, double? threshold, String? thresholdMetricId, String? treatMissingData, StandardUnit? unit}) → Future<void> - Creates or updates an alarm and associates it with the specified metric, metric math expression, anomaly detection model, Metrics Insights query, or PromQL query. For more information about using a Metrics Insights query for an alarm, see Create alarms on Metrics Insights queries.
-
putMetricData(
{required String namespace, List< EntityMetricData> ? entityMetricData, List<MetricDatum> ? metricData, bool? strictEntityValidation}) → Future<void> - Publishes metric data to Amazon CloudWatch. CloudWatch associates the data with the specified metric. If the specified metric does not exist, CloudWatch creates the metric. When CloudWatch creates a metric, it can take up to fifteen minutes for the metric to appear in calls to ListMetrics.
-
putMetricStream(
{required String firehoseArn, required String name, required MetricStreamOutputFormat outputFormat, required String roleArn, List< MetricStreamFilter> ? excludeFilters, List<MetricStreamFilter> ? includeFilters, bool? includeLinkedAccountsMetrics, List<MetricStreamStatisticsConfiguration> ? statisticsConfigurations, List<Tag> ? tags}) → Future<PutMetricStreamOutput> - Creates or updates a metric stream. Metric streams can automatically stream CloudWatch metrics to Amazon Web Services destinations, including Amazon S3, and to many third-party solutions.
-
setAlarmState(
{required String alarmName, required String stateReason, required StateValue stateValue, String? stateReasonData}) → Future< void> -
Temporarily sets the state of an alarm for testing purposes. When the
updated state differs from the previous value, the action configured for
the appropriate state is invoked. For example, if your alarm is configured
to send an Amazon SNS message when an alarm is triggered, temporarily
changing the alarm state to
ALARMsends an SNS message. -
startMetricStreams(
{required List< String> names}) → Future<void> - Starts the streaming of metrics for one or more of your metric streams.
-
startOTelEnrichment(
) → Future< void> -
Enables enrichment and PromQL access for CloudWatch vended metrics for supported
Amazon Web Services resources in the account. Once enabled, metrics
that contain a resource identifier dimension (for example, EC2
CPUUtilizationwith anInstanceIddimension) are enriched with resource ARN and resource tag labels and become queryable using PromQL. -
stopMetricStreams(
{required List< String> names}) → Future<void> - Stops the streaming of metrics for one or more of your metric streams.
-
stopOTelEnrichment(
) → Future< void> - Disables enrichment and PromQL access for CloudWatch vended metrics for supported Amazon Web Services resources in the account. After disabling, these metrics are no longer enriched with resource ARN and resource tag labels, and cannot be queried using PromQL.
-
tagResource(
{required String resourceARN, required List< Tag> tags}) → Future<void> - Assigns one or more tags (key-value pairs) to the specified CloudWatch resource. Currently, the only CloudWatch resources that can be tagged are alarms, dashboards, metric streams and Contributor Insights rules.
-
toString(
) → String -
A string representation of this object.
inherited
-
untagResource(
{required String resourceARN, required List< String> tagKeys}) → Future<void> - Removes one or more tags from the specified resource. Currently, alarms, dashboards, metric streams and Contributor Insights rules support tagging.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited