AWSCloudWatch
Objective-C
@interface AWSCloudWatch
Swift
class AWSCloudWatch
Amazon CloudWatch monitors your Amazon Web Services (AWS) resources and the applications you run on AWS 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 AWS, you can monitor your own custom metrics. With CloudWatch, you gain system-wide visibility into resource utilization, application performance, and operational health.
-
The service configuration used to instantiate this service client.
Warning
Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.Declaration
Objective-C
@property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration
-
Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with
defaultServiceConfiguration
from[AWSServiceManager defaultServiceManager]
. The reference to this object is maintained by the SDK, and you do not need to retain it manually.For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration return true
}
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider]; [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; return YES; }
Then call the following to get the default service client:
Swift
let CloudWatch = AWSCloudWatch.default()
Objective-C
AWSCloudWatch *CloudWatch = [AWSCloudWatch defaultCloudWatch];
Declaration
Objective-C
+ (nonnull instancetype)defaultCloudWatch;
Swift
class func `default`() -> Self
Return Value
The default service client.
-
Creates a service client with the given service configuration and registers it for the key.
For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider) AWSCloudWatch.register(with: configuration!, forKey: "USWest2CloudWatch") return true
}
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider]; [AWSCloudWatch registerCloudWatchWithConfiguration:configuration forKey:@"USWest2CloudWatch"]; return YES; }
Then call the following to get the service client:
Swift
let CloudWatch = AWSCloudWatch(forKey: "USWest2CloudWatch")
Objective-C
AWSCloudWatch *CloudWatch = [AWSCloudWatch CloudWatchForKey:@"USWest2CloudWatch"];
Warning
After calling this method, do not modify the configuration object. It may cause unspecified behaviors.
Declaration
Objective-C
+ (void)registerCloudWatchWithConfiguration:(id)configuration forKey:(nonnull NSString *)key;
Swift
class func register(withConfiguration configuration: Any!, forKey key: String)
Parameters
configuration
A service configuration object.
key
A string to identify the service client.
-
Retrieves the service client associated with the key. You need to call
+ registerCloudWatchWithConfiguration:forKey:
before invoking this method.For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider) AWSCloudWatch.register(with: configuration!, forKey: "USWest2CloudWatch") return true
}
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider]; [AWSCloudWatch registerCloudWatchWithConfiguration:configuration forKey:@"USWest2CloudWatch"]; return YES; }
Then call the following to get the service client:
Swift
let CloudWatch = AWSCloudWatch(forKey: "USWest2CloudWatch")
Objective-C
AWSCloudWatch *CloudWatch = [AWSCloudWatch CloudWatchForKey:@"USWest2CloudWatch"];
Declaration
Objective-C
+ (nonnull instancetype)CloudWatchForKey:(nonnull NSString *)key;
Swift
convenience init(forKey key: String)
Parameters
key
A string to identify the service client.
Return Value
An instance of the service client.
-
Removes the service client associated with the key and release it.
Warning
Before calling this method, make sure no method is running on this client.
Declaration
Objective-C
+ (void)removeCloudWatchForKey:(nonnull NSString *)key;
Swift
class func remove(forKey key: String)
Parameters
key
A string to identify the service client.
-
Deletes the specified alarms. In the event of an error, no alarms are deleted.
See
AWSCloudWatchDeleteAlarmsInput
Declaration
Objective-C
- (id)deleteAlarms:(nonnull AWSCloudWatchDeleteAlarmsInput *)request;
Swift
func deleteAlarms(_ request: AWSCloudWatchDeleteAlarmsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DeleteAlarms service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorResourceNotFound
. -
Deletes the specified alarms. In the event of an error, no alarms are deleted.
See
AWSCloudWatchDeleteAlarmsInput
Declaration
Objective-C
- (void)deleteAlarms:(nonnull AWSCloudWatchDeleteAlarmsInput *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func deleteAlarms(_ request: AWSCloudWatchDeleteAlarmsInput) async throws
Parameters
request
A container for the necessary parameters to execute the DeleteAlarms service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorResourceNotFound
. -
Deletes all dashboards that you specify. You may specify up to 100 dashboards to delete. If there is an error during this call, no dashboards are deleted.
See
AWSCloudWatchDeleteDashboardsInput
See
AWSCloudWatchDeleteDashboardsOutput
Declaration
Objective-C
- (id)deleteDashboards:(nonnull AWSCloudWatchDeleteDashboardsInput *)request;
Swift
func deleteDashboards(_ request: AWSCloudWatchDeleteDashboardsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DeleteDashboards service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchDeleteDashboardsOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorDashboardNotFound
,AWSCloudWatchErrorInternalService
. -
Deletes all dashboards that you specify. You may specify up to 100 dashboards to delete. If there is an error during this call, no dashboards are deleted.
See
AWSCloudWatchDeleteDashboardsInput
See
AWSCloudWatchDeleteDashboardsOutput
Declaration
Objective-C
- (void)deleteDashboards:(nonnull AWSCloudWatchDeleteDashboardsInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchDeleteDashboardsOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func deleteDashboards(_ request: AWSCloudWatchDeleteDashboardsInput) async throws -> AWSCloudWatchDeleteDashboardsOutput
Parameters
request
A container for the necessary parameters to execute the DeleteDashboards service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorDashboardNotFound
,AWSCloudWatchErrorInternalService
. -
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 all alarms are returned.
CloudWatch retains the history of an alarm even if you delete the alarm.
See
AWSCloudWatchDescribeAlarmHistoryInput
See
AWSCloudWatchDescribeAlarmHistoryOutput
Declaration
Objective-C
- (id)describeAlarmHistory: (nonnull AWSCloudWatchDescribeAlarmHistoryInput *)request;
Swift
func describeAlarmHistory(_ request: AWSCloudWatchDescribeAlarmHistoryInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DescribeAlarmHistory service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchDescribeAlarmHistoryOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
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 all alarms are returned.
CloudWatch retains the history of an alarm even if you delete the alarm.
See
AWSCloudWatchDescribeAlarmHistoryInput
See
AWSCloudWatchDescribeAlarmHistoryOutput
Declaration
Objective-C
- (void)describeAlarmHistory: (nonnull AWSCloudWatchDescribeAlarmHistoryInput *)request completionHandler: (void (^_Nullable)( AWSCloudWatchDescribeAlarmHistoryOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func describeAlarmHistory(_ request: AWSCloudWatchDescribeAlarmHistoryInput) async throws -> AWSCloudWatchDescribeAlarmHistoryOutput
Parameters
request
A container for the necessary parameters to execute the DescribeAlarmHistory service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
Retrieves the specified alarms. If no alarms are specified, all alarms are returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.
See
AWSCloudWatchDescribeAlarmsInput
See
AWSCloudWatchDescribeAlarmsOutput
Declaration
Objective-C
- (id)describeAlarms:(nonnull AWSCloudWatchDescribeAlarmsInput *)request;
Swift
func describeAlarms(_ request: AWSCloudWatchDescribeAlarmsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DescribeAlarms service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchDescribeAlarmsOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
Retrieves the specified alarms. If no alarms are specified, all alarms are returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.
See
AWSCloudWatchDescribeAlarmsInput
See
AWSCloudWatchDescribeAlarmsOutput
Declaration
Objective-C
- (void)describeAlarms:(nonnull AWSCloudWatchDescribeAlarmsInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchDescribeAlarmsOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func describeAlarms(_ request: AWSCloudWatchDescribeAlarmsInput) async throws -> AWSCloudWatchDescribeAlarmsOutput
Parameters
request
A container for the necessary parameters to execute the DescribeAlarms service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.
See
AWSCloudWatchDescribeAlarmsForMetricInput
See
AWSCloudWatchDescribeAlarmsForMetricOutput
Declaration
Objective-C
- (id)describeAlarmsForMetric: (nonnull AWSCloudWatchDescribeAlarmsForMetricInput *)request;
Swift
func describeAlarms(forMetric request: AWSCloudWatchDescribeAlarmsForMetricInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DescribeAlarmsForMetric service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchDescribeAlarmsForMetricOutput
. -
Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.
See
AWSCloudWatchDescribeAlarmsForMetricInput
See
AWSCloudWatchDescribeAlarmsForMetricOutput
Declaration
Objective-C
- (void)describeAlarmsForMetric: (nonnull AWSCloudWatchDescribeAlarmsForMetricInput *)request completionHandler: (void (^_Nullable)( AWSCloudWatchDescribeAlarmsForMetricOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func describeAlarms(forMetric request: AWSCloudWatchDescribeAlarmsForMetricInput) async throws -> AWSCloudWatchDescribeAlarmsForMetricOutput
Parameters
request
A container for the necessary parameters to execute the DescribeAlarmsForMetric service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. -
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.
See
AWSCloudWatchDisableAlarmActionsInput
Declaration
Objective-C
- (id)disableAlarmActions: (nonnull AWSCloudWatchDisableAlarmActionsInput *)request;
Swift
func disableAlarmActions(_ request: AWSCloudWatchDisableAlarmActionsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the DisableAlarmActions service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. -
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.
See
AWSCloudWatchDisableAlarmActionsInput
Declaration
Objective-C
- (void)disableAlarmActions: (nonnull AWSCloudWatchDisableAlarmActionsInput *)request completionHandler: (void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func disableAlarmActions(_ request: AWSCloudWatchDisableAlarmActionsInput) async throws
Parameters
request
A container for the necessary parameters to execute the DisableAlarmActions service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. -
Enables the actions for the specified alarms.
See
AWSCloudWatchEnableAlarmActionsInput
Declaration
Objective-C
- (id)enableAlarmActions: (nonnull AWSCloudWatchEnableAlarmActionsInput *)request;
Swift
func enableAlarmActions(_ request: AWSCloudWatchEnableAlarmActionsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the EnableAlarmActions service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. -
Enables the actions for the specified alarms.
See
AWSCloudWatchEnableAlarmActionsInput
Declaration
Objective-C
- (void) enableAlarmActions:(nonnull AWSCloudWatchEnableAlarmActionsInput *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func enableAlarmActions(_ request: AWSCloudWatchEnableAlarmActionsInput) async throws
Parameters
request
A container for the necessary parameters to execute the EnableAlarmActions service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. -
Displays the details of the dashboard that you specify.
To copy an existing dashboard, use
GetDashboard
, and then use the data returned withinDashboardBody
as the template for the new dashboard when you callPutDashboard
to create the copy.See
AWSCloudWatchGetDashboardInput
See
AWSCloudWatchGetDashboardOutput
Declaration
Objective-C
- (id)getDashboard:(nonnull AWSCloudWatchGetDashboardInput *)request;
Swift
func getDashboard(_ request: AWSCloudWatchGetDashboardInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the GetDashboard service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchGetDashboardOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorDashboardNotFound
,AWSCloudWatchErrorInternalService
. -
Displays the details of the dashboard that you specify.
To copy an existing dashboard, use
GetDashboard
, and then use the data returned withinDashboardBody
as the template for the new dashboard when you callPutDashboard
to create the copy.See
AWSCloudWatchGetDashboardInput
See
AWSCloudWatchGetDashboardOutput
Declaration
Objective-C
- (void)getDashboard:(nonnull AWSCloudWatchGetDashboardInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchGetDashboardOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func dashboard(_ request: AWSCloudWatchGetDashboardInput) async throws -> AWSCloudWatchGetDashboardOutput
Parameters
request
A container for the necessary parameters to execute the GetDashboard service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorDashboardNotFound
,AWSCloudWatchErrorInternalService
. -
You can use the
GetMetricData
API to retrieve as many as 100 different metrics in a single request, with a total of as many as 100,800 datapoints. You can also optionally perform math expressions on the values of the returned statistics, to create new time series that represent new insights into your data. For example, using Lambda metrics, you could divide the Errors metric by the Invocations metric to get an error rate time series. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.Calls to the
GetMetricData
API have a different pricing structure than calls toGetMetricStatistics
. For more information about pricing, see Amazon CloudWatch Pricing.Amazon CloudWatch retains metric data as follows:
Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution metrics and are available only for custom metrics that have been defined with a
StorageResolution
of 1.Data points with a period of 60 seconds (1-minute) are available for 15 days.
Data points with a period of 300 seconds (5-minute) are available for 63 days.
Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).
Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with a resolution of 1 hour.
See
AWSCloudWatchGetMetricDataInput
See
AWSCloudWatchGetMetricDataOutput
Declaration
Objective-C
- (id)getMetricData:(nonnull AWSCloudWatchGetMetricDataInput *)request;
Swift
func getMetricData(_ request: AWSCloudWatchGetMetricDataInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the GetMetricData service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchGetMetricDataOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
You can use the
GetMetricData
API to retrieve as many as 100 different metrics in a single request, with a total of as many as 100,800 datapoints. You can also optionally perform math expressions on the values of the returned statistics, to create new time series that represent new insights into your data. For example, using Lambda metrics, you could divide the Errors metric by the Invocations metric to get an error rate time series. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.Calls to the
GetMetricData
API have a different pricing structure than calls toGetMetricStatistics
. For more information about pricing, see Amazon CloudWatch Pricing.Amazon CloudWatch retains metric data as follows:
Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution metrics and are available only for custom metrics that have been defined with a
StorageResolution
of 1.Data points with a period of 60 seconds (1-minute) are available for 15 days.
Data points with a period of 300 seconds (5-minute) are available for 63 days.
Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).
Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with a resolution of 1 hour.
See
AWSCloudWatchGetMetricDataInput
See
AWSCloudWatchGetMetricDataOutput
Declaration
Objective-C
- (void)getMetricData:(nonnull AWSCloudWatchGetMetricDataInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchGetMetricDataOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func metricData(_ request: AWSCloudWatchGetMetricDataInput) async throws -> AWSCloudWatchGetMetricDataOutput
Parameters
request
A container for the necessary parameters to execute the GetMetricData service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidNextToken
. -
Gets statistics for the specified metric.
The maximum number of data points returned from a single call is 1,440. If you request more than 1,440 data points, CloudWatch returns an error. To reduce the number of data points, you can narrow the specified time range and make multiple requests across adjacent time ranges, or you can increase the specified period. Data points are not returned in chronological order.
CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request statistics with a one-hour period, CloudWatch aggregates all data points with time stamps that fall within each one-hour period. Therefore, the number of values aggregated by CloudWatch is larger than the number of data points returned.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:
The SampleCount value of the statistic set is 1.
The Min and the Max values of the statistic set are equal.
Percentile statistics are not available for metrics when any of the metric values are negative numbers.
Amazon CloudWatch retains metric data as follows:
Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution metrics and are available only for custom metrics that have been defined with a
StorageResolution
of 1.Data points with a period of 60 seconds (1-minute) are available for 15 days.
Data points with a period of 300 seconds (5-minute) are available for 63 days.
Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).
Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with a resolution of 1 hour.
CloudWatch started retaining 5-minute and 1-hour metric data as of July 9, 2016.
For information about metrics and dimensions supported by AWS services, see the Amazon CloudWatch Metrics and Dimensions Reference in the Amazon CloudWatch User Guide.
See
AWSCloudWatchGetMetricStatisticsInput
See
AWSCloudWatchGetMetricStatisticsOutput
Declaration
Objective-C
- (id)getMetricStatistics: (nonnull AWSCloudWatchGetMetricStatisticsInput *)request;
Swift
func getMetricStatistics(_ request: AWSCloudWatchGetMetricStatisticsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the GetMetricStatistics service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchGetMetricStatisticsOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorMissingRequiredParameter
,AWSCloudWatchErrorInvalidParameterCombination
,AWSCloudWatchErrorInternalService
. -
Gets statistics for the specified metric.
The maximum number of data points returned from a single call is 1,440. If you request more than 1,440 data points, CloudWatch returns an error. To reduce the number of data points, you can narrow the specified time range and make multiple requests across adjacent time ranges, or you can increase the specified period. Data points are not returned in chronological order.
CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request statistics with a one-hour period, CloudWatch aggregates all data points with time stamps that fall within each one-hour period. Therefore, the number of values aggregated by CloudWatch is larger than the number of data points returned.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:
The SampleCount value of the statistic set is 1.
The Min and the Max values of the statistic set are equal.
Percentile statistics are not available for metrics when any of the metric values are negative numbers.
Amazon CloudWatch retains metric data as follows:
Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution metrics and are available only for custom metrics that have been defined with a
StorageResolution
of 1.Data points with a period of 60 seconds (1-minute) are available for 15 days.
Data points with a period of 300 seconds (5-minute) are available for 63 days.
Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).
Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with a resolution of 1 hour.
CloudWatch started retaining 5-minute and 1-hour metric data as of July 9, 2016.
For information about metrics and dimensions supported by AWS services, see the Amazon CloudWatch Metrics and Dimensions Reference in the Amazon CloudWatch User Guide.
See
AWSCloudWatchGetMetricStatisticsInput
See
AWSCloudWatchGetMetricStatisticsOutput
Declaration
Objective-C
- (void) getMetricStatistics:(nonnull AWSCloudWatchGetMetricStatisticsInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchGetMetricStatisticsOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func metricStatistics(_ request: AWSCloudWatchGetMetricStatisticsInput) async throws -> AWSCloudWatchGetMetricStatisticsOutput
Parameters
request
A container for the necessary parameters to execute the GetMetricStatistics service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorMissingRequiredParameter
,AWSCloudWatchErrorInvalidParameterCombination
,AWSCloudWatchErrorInternalService
. -
You can use the
GetMetricWidgetImage
API 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.The graph you retrieve can include all CloudWatch metric graph features, including metric math and horizontal and vertical annotations.
There is a limit of 20 transactions per second for this API. Each
GetMetricWidgetImage
action has the following limits:As many as 100 metrics in the graph.
Up to 100 KB uncompressed payload.
See
AWSCloudWatchGetMetricWidgetImageInput
See
AWSCloudWatchGetMetricWidgetImageOutput
Declaration
Objective-C
- (id)getMetricWidgetImage: (nonnull AWSCloudWatchGetMetricWidgetImageInput *)request;
Swift
func getMetricWidgetImage(_ request: AWSCloudWatchGetMetricWidgetImageInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the GetMetricWidgetImage service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchGetMetricWidgetImageOutput
. -
You can use the
GetMetricWidgetImage
API 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.The graph you retrieve can include all CloudWatch metric graph features, including metric math and horizontal and vertical annotations.
There is a limit of 20 transactions per second for this API. Each
GetMetricWidgetImage
action has the following limits:As many as 100 metrics in the graph.
Up to 100 KB uncompressed payload.
See
AWSCloudWatchGetMetricWidgetImageInput
See
AWSCloudWatchGetMetricWidgetImageOutput
Declaration
Objective-C
- (void)getMetricWidgetImage: (nonnull AWSCloudWatchGetMetricWidgetImageInput *)request completionHandler: (void (^_Nullable)( AWSCloudWatchGetMetricWidgetImageOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func metricWidgetImage(_ request: AWSCloudWatchGetMetricWidgetImageInput) async throws -> AWSCloudWatchGetMetricWidgetImageOutput
Parameters
request
A container for the necessary parameters to execute the GetMetricWidgetImage service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. -
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.ListDashboards
returns up to 1000 results on one page. If there are more than 1000 dashboards, you can callListDashboards
again and include the value you received forNextToken
in the first call, to receive the next 1000 results.See
AWSCloudWatchListDashboardsInput
See
AWSCloudWatchListDashboardsOutput
Declaration
Objective-C
- (id)listDashboards:(nonnull AWSCloudWatchListDashboardsInput *)request;
Swift
func listDashboards(_ request: AWSCloudWatchListDashboardsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the ListDashboards service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchListDashboardsOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorInternalService
. -
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.ListDashboards
returns up to 1000 results on one page. If there are more than 1000 dashboards, you can callListDashboards
again and include the value you received forNextToken
in the first call, to receive the next 1000 results.See
AWSCloudWatchListDashboardsInput
See
AWSCloudWatchListDashboardsOutput
Declaration
Objective-C
- (void)listDashboards:(nonnull AWSCloudWatchListDashboardsInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchListDashboardsOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func listDashboards(_ request: AWSCloudWatchListDashboardsInput) async throws -> AWSCloudWatchListDashboardsOutput
Parameters
request
A container for the necessary parameters to execute the ListDashboards service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorInternalService
. -
List the specified metrics. You can use the returned metrics with GetMetricData or GetMetricStatistics to obtain 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 fifteen minutes before the metric appears. Statistics about the metric, however, are available sooner using GetMetricData or GetMetricStatistics.
See
AWSCloudWatchListMetricsInput
See
AWSCloudWatchListMetricsOutput
Declaration
Objective-C
- (id)listMetrics:(nonnull AWSCloudWatchListMetricsInput *)request;
Swift
func listMetrics(_ request: AWSCloudWatchListMetricsInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the ListMetrics service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchListMetricsOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInternalService
,AWSCloudWatchErrorInvalidParameterValue
. -
List the specified metrics. You can use the returned metrics with GetMetricData or GetMetricStatistics to obtain 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 fifteen minutes before the metric appears. Statistics about the metric, however, are available sooner using GetMetricData or GetMetricStatistics.
See
AWSCloudWatchListMetricsInput
See
AWSCloudWatchListMetricsOutput
Declaration
Objective-C
- (void)listMetrics:(nonnull AWSCloudWatchListMetricsInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchListMetricsOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func listMetrics(_ request: AWSCloudWatchListMetricsInput) async throws -> AWSCloudWatchListMetricsOutput
Parameters
request
A container for the necessary parameters to execute the ListMetrics service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInternalService
,AWSCloudWatchErrorInvalidParameterValue
. -
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.
There is no limit to the number of dashboards in your account. All dashboards in your account are global, not region-specific.
A simple way to create a dashboard using
PutDashboard
is to copy an existing dashboard. To copy an existing dashboard using the console, you can load the dashboard and then use the View/edit source command in the Actions menu to display the JSON block for that dashboard. Another way to copy a dashboard is to useGetDashboard
, and then use the data returned withinDashboardBody
as the template for the new dashboard when you callPutDashboard
.When you create a dashboard with
PutDashboard
, a good practice is to add a text widget at the top of the dashboard with a message that the dashboard was created by script and should not be changed in the console. This message could also point console users to the location of theDashboardBody
script or the CloudFormation template used to create the dashboard.See
AWSCloudWatchPutDashboardInput
See
AWSCloudWatchPutDashboardOutput
Declaration
Objective-C
- (id)putDashboard:(nonnull AWSCloudWatchPutDashboardInput *)request;
Swift
func putDashboard(_ request: AWSCloudWatchPutDashboardInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the PutDashboard service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSCloudWatchPutDashboardOutput
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorDashboardInvalidInput
,AWSCloudWatchErrorInternalService
. -
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.
There is no limit to the number of dashboards in your account. All dashboards in your account are global, not region-specific.
A simple way to create a dashboard using
PutDashboard
is to copy an existing dashboard. To copy an existing dashboard using the console, you can load the dashboard and then use the View/edit source command in the Actions menu to display the JSON block for that dashboard. Another way to copy a dashboard is to useGetDashboard
, and then use the data returned withinDashboardBody
as the template for the new dashboard when you callPutDashboard
.When you create a dashboard with
PutDashboard
, a good practice is to add a text widget at the top of the dashboard with a message that the dashboard was created by script and should not be changed in the console. This message could also point console users to the location of theDashboardBody
script or the CloudFormation template used to create the dashboard.See
AWSCloudWatchPutDashboardInput
See
AWSCloudWatchPutDashboardOutput
Declaration
Objective-C
- (void)putDashboard:(nonnull AWSCloudWatchPutDashboardInput *)request completionHandler: (void (^_Nullable)(AWSCloudWatchPutDashboardOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func putDashboard(_ request: AWSCloudWatchPutDashboardInput) async throws -> AWSCloudWatchPutDashboardOutput
Parameters
request
A container for the necessary parameters to execute the PutDashboard service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorDashboardInvalidInput
,AWSCloudWatchErrorInternalService
. -
Creates or updates an alarm and associates it with the specified metric or metric math expression.
When this operation creates an alarm, the alarm state is immediately set to
INSUFFICIENT_DATA
. The alarm is then evaluated and its state is set appropriately. Any actions associated with the new state are then executed.When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
If you are an IAM user, you must have Amazon EC2 permissions for some alarm operations:
iam:CreateServiceLinkedRole
for all alarms with EC2 actionsec2:DescribeInstanceStatus
andec2:DescribeInstances
for all alarms on EC2 instance status metricsec2:StopInstances
for alarms with stop actionsec2:TerminateInstances
for alarms with terminate actionsec2:DescribeInstanceRecoveryAttribute
andec2:RecoverInstances
for alarms with recover actions
If you have read/write permissions for Amazon CloudWatch but not for Amazon EC2, you can still create an alarm, but the stop or terminate actions are not performed. However, if you are later granted the required permissions, the alarm actions that you created earlier are performed.
If you are using an IAM role (for example, an EC2 instance profile), you cannot stop or terminate the instance using alarm actions. However, you can still see the alarm state and perform any other actions such as Amazon SNS notifications or Auto Scaling policies.
If you are using temporary security credentials granted using AWS STS, you cannot stop or terminate an EC2 instance using alarm actions.
The first time you create an alarm in the AWS Management Console, the CLI, or by using the PutMetricAlarm API, CloudWatch creates the necessary service-linked role for you. The service-linked role is called
AWSServiceRoleForCloudWatchEvents
. For more information, see AWS service-linked role.See
AWSCloudWatchPutMetricAlarmInput
Declaration
Objective-C
- (id)putMetricAlarm:(nonnull AWSCloudWatchPutMetricAlarmInput *)request;
Swift
func putMetricAlarm(_ request: AWSCloudWatchPutMetricAlarmInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the PutMetricAlarm service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorLimitExceeded
. -
Creates or updates an alarm and associates it with the specified metric or metric math expression.
When this operation creates an alarm, the alarm state is immediately set to
INSUFFICIENT_DATA
. The alarm is then evaluated and its state is set appropriately. Any actions associated with the new state are then executed.When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
If you are an IAM user, you must have Amazon EC2 permissions for some alarm operations:
iam:CreateServiceLinkedRole
for all alarms with EC2 actionsec2:DescribeInstanceStatus
andec2:DescribeInstances
for all alarms on EC2 instance status metricsec2:StopInstances
for alarms with stop actionsec2:TerminateInstances
for alarms with terminate actionsec2:DescribeInstanceRecoveryAttribute
andec2:RecoverInstances
for alarms with recover actions
If you have read/write permissions for Amazon CloudWatch but not for Amazon EC2, you can still create an alarm, but the stop or terminate actions are not performed. However, if you are later granted the required permissions, the alarm actions that you created earlier are performed.
If you are using an IAM role (for example, an EC2 instance profile), you cannot stop or terminate the instance using alarm actions. However, you can still see the alarm state and perform any other actions such as Amazon SNS notifications or Auto Scaling policies.
If you are using temporary security credentials granted using AWS STS, you cannot stop or terminate an EC2 instance using alarm actions.
The first time you create an alarm in the AWS Management Console, the CLI, or by using the PutMetricAlarm API, CloudWatch creates the necessary service-linked role for you. The service-linked role is called
AWSServiceRoleForCloudWatchEvents
. For more information, see AWS service-linked role.See
AWSCloudWatchPutMetricAlarmInput
Declaration
Objective-C
- (void)putMetricAlarm:(nonnull AWSCloudWatchPutMetricAlarmInput *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func putMetricAlarm(_ request: AWSCloudWatchPutMetricAlarmInput) async throws
Parameters
request
A container for the necessary parameters to execute the PutMetricAlarm service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorLimitExceeded
. -
Publishes metric data points to Amazon CloudWatch. CloudWatch associates the data points 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.
You can publish either individual data points in the
Value
field, or arrays of values and the number of times each value occurred during the period by using theValues
andCounts
fields in theMetricDatum
structure. Using theValues
andCounts
method enables you to publish up to 150 values per metric with onePutMetricData
request, and supports retrieving percentile statistics on this data.Each
PutMetricData
request is limited to 40 KB in size for HTTP POST requests. You can send a payload compressed by gzip. Each request is also limited to no more than 20 different metrics.Although the
Value
parameter accepts numbers of typeDouble
, CloudWatch rejects values that are either too small or too large. Values must be in the range of 8.515920e-109 to 1.174271e+108 (Base 10) or 2e-360 to 2e360 (Base 2). In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.You can use up to 10 dimensions per metric to further clarify what data the metric collects. For more information about specifying dimensions, see Publishing Metrics in the Amazon CloudWatch User Guide.
Data points with time stamps from 24 hours ago or longer can take at least 48 hours to become available for GetMetricData or GetMetricStatistics from the time they are submitted.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:
The
SampleCount
value of the statistic set is 1 andMin
,Max
, andSum
are all equal.The
Min
andMax
are equal, andSum
is equal toMin
multiplied bySampleCount
.
See
AWSCloudWatchPutMetricDataInput
Declaration
Objective-C
- (id)putMetricData:(nonnull AWSCloudWatchPutMetricDataInput *)request;
Swift
func putMetricData(_ request: AWSCloudWatchPutMetricDataInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the PutMetricData service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorMissingRequiredParameter
,AWSCloudWatchErrorInvalidParameterCombination
,AWSCloudWatchErrorInternalService
. -
Publishes metric data points to Amazon CloudWatch. CloudWatch associates the data points 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.
You can publish either individual data points in the
Value
field, or arrays of values and the number of times each value occurred during the period by using theValues
andCounts
fields in theMetricDatum
structure. Using theValues
andCounts
method enables you to publish up to 150 values per metric with onePutMetricData
request, and supports retrieving percentile statistics on this data.Each
PutMetricData
request is limited to 40 KB in size for HTTP POST requests. You can send a payload compressed by gzip. Each request is also limited to no more than 20 different metrics.Although the
Value
parameter accepts numbers of typeDouble
, CloudWatch rejects values that are either too small or too large. Values must be in the range of 8.515920e-109 to 1.174271e+108 (Base 10) or 2e-360 to 2e360 (Base 2). In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.You can use up to 10 dimensions per metric to further clarify what data the metric collects. For more information about specifying dimensions, see Publishing Metrics in the Amazon CloudWatch User Guide.
Data points with time stamps from 24 hours ago or longer can take at least 48 hours to become available for GetMetricData or GetMetricStatistics from the time they are submitted.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:
The
SampleCount
value of the statistic set is 1 andMin
,Max
, andSum
are all equal.The
Min
andMax
are equal, andSum
is equal toMin
multiplied bySampleCount
.
See
AWSCloudWatchPutMetricDataInput
Declaration
Objective-C
- (void)putMetricData:(nonnull AWSCloudWatchPutMetricDataInput *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func putMetricData(_ request: AWSCloudWatchPutMetricDataInput) async throws
Parameters
request
A container for the necessary parameters to execute the PutMetricData service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorInvalidParameterValue
,AWSCloudWatchErrorMissingRequiredParameter
,AWSCloudWatchErrorInvalidParameterCombination
,AWSCloudWatchErrorInternalService
. -
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
ALARM
sends an SNS message. The alarm returns to its actual state (often within seconds). Because the alarm state change happens quickly, it is typically only visible in the alarm’s History tab in the Amazon CloudWatch console or through DescribeAlarmHistory.See
AWSCloudWatchSetAlarmStateInput
Declaration
Objective-C
- (id)setAlarmState:(nonnull AWSCloudWatchSetAlarmStateInput *)request;
Swift
func setAlarmState(_ request: AWSCloudWatchSetAlarmStateInput) -> Any!
Parameters
request
A container for the necessary parameters to execute the SetAlarmState service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. On failed execution,task.error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorResourceNotFound
,AWSCloudWatchErrorInvalidFormat
. -
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
ALARM
sends an SNS message. The alarm returns to its actual state (often within seconds). Because the alarm state change happens quickly, it is typically only visible in the alarm’s History tab in the Amazon CloudWatch console or through DescribeAlarmHistory.See
AWSCloudWatchSetAlarmStateInput
Declaration
Objective-C
- (void)setAlarmState:(nonnull AWSCloudWatchSetAlarmStateInput *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func setAlarmState(_ request: AWSCloudWatchSetAlarmStateInput) async throws
Parameters
request
A container for the necessary parameters to execute the SetAlarmState service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSCloudWatchErrorDomain
domain and the following error code:AWSCloudWatchErrorResourceNotFound
,AWSCloudWatchErrorInvalidFormat
.