Package | com.amazonaws.services.cloudwatch |
Class | public class AmazonCloudWatchClient |
Inheritance | AmazonCloudWatchClient ![]() ![]() |
Implements | AmazonCloudWatch |
Language Version : | ActionScript 3.0 |
Product Version : | Flex 4 |
Since : | July 12. 2011 |
Runtime Versions : | Flash Player 10.1, AIR 2.5 |
Method | Defined By | ||
---|---|---|---|
AmazonCloudWatchClient | |||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void [override]
| AmazonCloudWatchClient | ||
dispatchEvent(event:Event):Boolean [override]
| AmazonCloudWatchClient | ||
getMetricStatistics(getMetricStatisticsRequest:GetMetricStatisticsRequest = null):void
Gets statistics for the specified metric. | AmazonCloudWatchClient | ||
hasEventListener(type:String):Boolean [override]
| AmazonCloudWatchClient | ||
listMetrics(listMetricsRequest:ListMetricsRequest = null):void
Returns a list of valid metrics stored for the AWS account owner. | AmazonCloudWatchClient | ||
putMetricData(putMetricDataRequest:PutMetricDataRequest):void
Publishes metric data points to Amazon CloudWatch. | AmazonCloudWatchClient | ||
releaseResources():void
Removing all event listeners and releasing any resources that might be held open. | AmazonCloudWatchClient | ||
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void [override]
| AmazonCloudWatchClient | ||
willTrigger(type:String):Boolean [override]
| AmazonCloudWatchClient |
Event | Summary | Defined By | ||
---|---|---|---|---|
AmazonCloudWatchClient | ||||
AmazonCloudWatchClient | ||||
AmazonCloudWatchClient |
AmazonCloudWatchClient | () | Constructor |
public function AmazonCloudWatchClient(awsCredentials:AWSCredentials, clientConfiguration:ClientConfiguration)
Parameters
awsCredentials:AWSCredentials | |
clientConfiguration:ClientConfiguration |
addEventListener | () | method |
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Parameters
type:String | |
listener:Function | |
useCapture:Boolean (default = false )
| |
priority:int (default = 0 )
| |
useWeakReference:Boolean (default = false )
|
dispatchEvent | () | method |
override public function dispatchEvent(event:Event):Boolean
Parameters
event:Event |
Boolean |
getMetricStatistics | () | method |
public function getMetricStatistics(getMetricStatisticsRequest:GetMetricStatisticsRequest = null):void
Gets statistics for the specified metric.
NOTE: The maximum number of data points returned from a single GetMetricStatistics request is 1,440. If a request is made that generates more than 1,440 data points, Amazon CloudWatch returns an error. In such a case, alter the request by narrowing the specified time range or increasing the specified period. Alternatively, make multiple requests across adjacent time ranges. Amazon CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request statistics with a one-minute granularity, Amazon CloudWatch aggregates data points with time stamps that fall within the same one-minute period. In such a case, the data points queried can greatly outnumber the data points returned. NOTE: The maximum number of data points that can be queried is 50,850; whereas the maximum number of data points returned is 1,440. The following examples show various statistics allowed by the data point query maximum of 50,850 when you call GetMetricStatistics on Amazon EC2 instances with detailed (one-minute) monitoring enabled:Parameters
getMetricStatisticsRequest:GetMetricStatisticsRequest (default = null ) — Container for the necessary parameters to execute the GetMetricStatistics service method on AmazonCloudWatch.
|
— This error can occur for the following reasons:
1) Flash Player or AIR cannot convert the URLRequest.data parameter from UTF8 to MBCS.
This error is applicable if the URLRequest object passed to load() is set to perform
a GET operation and if System.useCodePage is set to true.
2) Flash Player or AIR cannot allocate memory for the POST data.
This error is applicable if the URLRequest object passed to load is set to perform a POST operation.
| |
— This error occurs when getMetricStatisticsRequest or one of getMetricStatisticsRequest parameters in null
| |
— You are trying to connect to a commonly reserved port.
For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
|
See also
// Function executes get metric statistics. public function getMetricStatistics(): void { var awsCredentials: AWSCredentials = new BasicAWSCredentials("your access key id", "your secret key"); var clientConfig: ClientConfiguration = new ClientConfiguration(); clientConfig.endpoint = "monitoring.eu-west-1.amazonaws.com"; clientConfig.protocol = ProtocolEnum.HTTPS; clientConfig.signatureExpires = 60; // signature expires after 60 seconds clientConfig.userAgent = "Funny User Agent"; (optional parameter - only for AIR Runtime) var client: AmazonCloudWatch = new AmazonCloudWatchClient(awsCredentials, clientConfig); var request: GetMetricStatisticsRequest = new GetMetricStatisticsRequest(); request.setPeriod(60); request.setUnit(StandardUnitEnum.COUNT.toString()); request.setStartTime(DateUtils.addHours(new Date(), -12)); // local datetime (getMetricStatistics will internally do ISO 8601 datetime conversion!) request.setEndTime(DateUtils.addHours(new Date(), -2)); // local datetime (getMetricStatistics will internally do ISO 8601 datetime conversion!) request.setNamespace("AWS/SQS"); request.setMetricName("ApproximateNumberOfMessagesVisible"); // ALL statistics var statistics: Array = new Array(); statistics.push(DatapointEnum.MAXIMUM); statistics.push(DatapointEnum.MINIMUM); statistics.push(DatapointEnum.SAMPLE_COUNT); statistics.push(DatapointEnum.SUM); statistics.push(DatapointEnum.AVERAGE); request.setStatistics(statistics); // dimension var dimensions: Array = new Array(); var dimension:Dimension = new Dimension(); dimension.setName("QueueName"); dimension.setValue("Test"); dimensions.push(dimension); request.setDimensions(dimensions); client.addEventListener(CompleteActionEvent.COMPLETE, resultHandler, false, 0, true); client.addEventListener(IOErrorActionEvent.IO_ERROR, faultHandler, false, 0, true); try { client.getMetricStatistics(request); } catch (error: Error) { // do something if error thrown } } // Asynchronous positive response. private function resultHandler(event: CompleteActionEvent): void { var result: GetMetricStatisticsResult = event.result as GetMetricStatisticsResult; var label:String = result.getLabel()(); var requestId: String = result.getRequestId(); for each (var dp: Datapoint in _datapoints) { var timestamp: Date = dp.getTimestamp(); var average: Number = dp.getAverage(); var maximum: Number = dp.getMaximum(); var minimum: Number = dp.getMinimum(); var sampleCount: Number = dp.getSampleCount(); var sum: Number = dp.getSum(); var unit: Number = dp.getUnit(); // do something with timestamp, average, maximum, minimum, sampleCount, sum and unit } // do something with label and requestId } // Asynchronous negative response. private function faultHandler(event: IOErrorActionEvent): void { var result: AmazonWebServiceErrorResult = event.result as AmazonWebServiceErrorResult; var type: String = result.getType(); var code: String = result.getCode(); var message: String = result.getMessage(); var detail: String = result.getDetail(); var requestId: String = result.getRequestId(); // do something with type, code, message, detail and requestId }
hasEventListener | () | method |
override public function hasEventListener(type:String):Boolean
Parameters
type:String |
Boolean |
listMetrics | () | method |
public function listMetrics(listMetricsRequest:ListMetricsRequest = null):void
Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used with GetMetricStatistics to obtain statistical data for a given metric.
NOTE: Up to 500 results are returned for any one call. To retrieve further results, use returned NextToken values with subsequent ListMetrics operations. NOTE: If you create a metric with the PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action.Parameters
listMetricsRequest:ListMetricsRequest (default = null ) — - Container for the necessary parameters to execute the ListMetrics service method on AmazonCloudWatch.
If set to null ALL available metrics will be returned.
|
— This error can occur for the following reasons:
1) Flash Player or AIR cannot convert the URLRequest.data parameter from UTF8 to MBCS.
This error is applicable if the URLRequest object passed to load() is set to perform
a GET operation and if System.useCodePage is set to true.
2) Flash Player or AIR cannot allocate memory for the POST data.
This error is applicable if the URLRequest object passed to load is set to perform a POST operation.
| |
— This error occurs when listMetricsRequest or one of listMetricsRequest parameters in null
| |
— You are trying to connect to a commonly reserved port.
For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
|
See also
// Function executes list metric data. public function listMetrics(): void { var awsCredentials: AWSCredentials = new BasicAWSCredentials("your access key id", "your secret key"); var clientConfig: ClientConfiguration = new ClientConfiguration(); clientConfig.endpoint = "monitoring.eu-west-1.amazonaws.com"; clientConfig.protocol = ProtocolEnum.HTTPS; clientConfig.signatureExpires = 60; // signature expires after 60 seconds clientConfig.userAgent = "Funny User Agent"; (optional parameter - only for AIR Runtime) var client: AmazonCloudWatch = new AmazonCloudWatchClient(awsCredentials, clientConfig); var request:ListMetricsRequest = new ListMetricsRequest(); request.setNamespace("AWS/SQS"); client.addEventListener(CompleteActionEvent.COMPLETE, resultHandler, false, 0, true); client.addEventListener(IOErrorActionEvent.IO_ERROR, faultHandler, false, 0, true); try { client.listMetrics(request); // if 'request' is null then all available metrics will be searched } catch (error: Error) { // do something if error thrown } } // Asynchronous positive response. private function resultHandler(event: CompleteActionEvent): void { var result: ListMetricsResult = event.result as ListMetricsResult; var nextToken:String = result.getNextToken(); var requestId: String = result.getRequestId(); for each (var metric: Metric in result.getMetrics()) { var metricName:String = metric.getMetricName(); var namespace:String = metric.getNamespace(); // do something with metricName and namespace for each (var dimension: Dimension in metric.getDimensions()) { var name:String = dimension.getName()); var value:String = dimension.getValue()); // do something with name and value } } // do something with nextToken and requestId } // Asynchronous negative response. private function faultHandler(event: IOErrorActionEvent): void { var result: AmazonWebServiceErrorResult = event.result as AmazonWebServiceErrorResult; var type: String = result.getType(); var code: String = result.getCode(); var message: String = result.getMessage(); var detail: String = result.getDetail(); var requestId: String = result.getRequestId(); // do something with type, code, message, detail and requestId }
putMetricData | () | method |
public function putMetricData(putMetricDataRequest:PutMetricDataRequest):void
Publishes metric data points to Amazon CloudWatch. Amazon Cloudwatch associates the data points with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates the metric.
NOTE: If you create a metric with the PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action. The size of a PutMetricData request is limited to 8 KB for HTTP GET requests and 40 KB for HTTP POST requests. IMPORTANT: Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated.Parameters
putMetricDataRequest:PutMetricDataRequest — - Container for the necessary parameters to execute the PutMetricData service method on AmazonCloudWatch.
|
— This error can occur for the following reasons:
1) Flash Player or AIR cannot convert the URLRequest.data parameter from UTF8 to MBCS.
This error is applicable if the URLRequest object passed to load() is set to perform
a GET operation and if System.useCodePage is set to true.
2) Flash Player or AIR cannot allocate memory for the POST data.
This error is applicable if the URLRequest object passed to load is set to perform a POST operation.
| |
— This error occurs when putMetricDataRequest or one of putMetricDataRequest parameters in null
| |
— You are trying to connect to a commonly reserved port.
For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
|
See also
// Function executes addition of metric data. public function putMetricData(): void { var awsCredentials: AWSCredentials = new BasicAWSCredentials("your access key id", "your secret key"); var clientConfig: ClientConfiguration = new ClientConfiguration(); clientConfig.endpoint = "monitoring.eu-west-1.amazonaws.com"; clientConfig.protocol = ProtocolEnum.HTTPS; clientConfig.signatureExpires = 60; // signature expires after 60 seconds clientConfig.userAgent = "Funny User Agent"; (optional parameter - only for AIR Runtime) var client: AmazonCloudWatch = new AmazonCloudWatchClient(awsCredentials, clientConfig); var request:PutMetricDataRequest = new PutMetricDataRequest(); request.setNamespace("TestNamespace"); var metricData: Array = new Array(); var metricDatum: MetricDatum = new MetricDatum(); metricDatum.setMetricName("TestMetric01"); metricDatum.setUnit("Count"); metricDatum.setValue(1000); var dimensionArray: Array = new Array(); var dimension:Dimension = new Dimension(); dimension.setName("DimensionTest1"); dimension.setValue("1"); dimensionArray.push(dimension); metricDatum.setDimensions(dimensionArray); metricData.push(metricDatum); request.setMetricData(metricData); client.addEventListener(CompleteActionEvent.COMPLETE, resultHandler, false, 0, true); client.addEventListener(IOErrorActionEvent.IO_ERROR, faultHandler, false, 0, true); try { client.putMetricData(request); } catch (error: Error) { // do something if error thrown } } // Asynchronous positive response. private function resultHandler(event: CompleteActionEvent): void { var result: PutMetricDataResult = event.result as PutMetricDataResult; var requestId: String = result.getRequestId(); // do something with requestId } // Asynchronous negative response. private function faultHandler(event: IOErrorActionEvent): void { var result: AmazonWebServiceErrorResult = event.result as AmazonWebServiceErrorResult; var type: String = result.getType(); var code: String = result.getCode(); var message: String = result.getMessage(); var detail: String = result.getDetail(); var requestId: String = result.getRequestId(); // do something with type, code, message, detail and requestId }
releaseResources | () | method |
public function releaseResources():void
Removing all event listeners and releasing any resources that might be held open.
removeEventListener | () | method |
override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Parameters
type:String | |
listener:Function | |
useCapture:Boolean (default = false )
|
willTrigger | () | method |
override public function willTrigger(type:String):Boolean
Parameters
type:String |
Boolean |
complete | Event |
ioError | Event |
securityError | Event |
flash.events.SecurityErrorEvent