libZSservicesZSamazonka-cloudwatchZSamazonka-cloudwatch
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.CloudWatch.GetMetricData

Description

You can use the GetMetricData API to retrieve as many as 500 different metrics in a single request, with a total of as many as 100,800 data points. 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 to GetMetricStatistics. 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.

If you omit Unit in your request, all data that was collected with any unit is returned, along with the corresponding units that were specified when the data was reported to CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit specified. If you specify a unit that does not match the data collected, the results of the operation are null. CloudWatch does not perform unit conversions.

This operation returns paginated results.

Synopsis

Creating a Request

data GetMetricData Source #

See: newGetMetricData smart constructor.

Constructors

GetMetricData' 

Fields

  • maxDatapoints :: Maybe Int

    The maximum number of data points the request should return before paginating. If you omit this, the default of 100,800 is used.

  • labelOptions :: Maybe LabelOptions

    This structure includes the Timezone parameter, which you can use to specify your time zone so that the labels of returned data display the correct time for your time zone.

  • nextToken :: Maybe Text

    Include this value, if it was returned by the previous GetMetricData operation, to get the next set of data points.

  • scanBy :: Maybe ScanBy

    The order in which data points should be returned. TimestampDescending returns the newest data first and paginates when the MaxDatapoints limit is reached. TimestampAscending returns the oldest data first and paginates when the MaxDatapoints limit is reached.

  • metricDataQueries :: [MetricDataQuery]

    The metric queries to be returned. A single GetMetricData call can include as many as 500 MetricDataQuery structures. Each of these structures can specify either a metric to retrieve, or a math expression to perform on retrieved data.

  • startTime :: ISO8601

    The time stamp indicating the earliest data to be returned.

    The value specified is inclusive; results include data points with the specified time stamp.

    CloudWatch rounds the specified time stamp as follows:

    • Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded down to 12:32:00.
    • Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, 12:32:34 is rounded down to 12:30:00.
    • Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, 12:32:34 is rounded down to 12:00:00.

    If you set Period to 5, 10, or 30, the start time of your request is rounded down to the nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15.

    For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as StartTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the StartTime.

  • endTime :: ISO8601

    The time stamp indicating the latest data to be returned.

    The value specified is exclusive; results include data points up to the specified time stamp.

    For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as EndTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the EndTime.

Instances

Instances details
Eq GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Read GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Show GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Generic GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Associated Types

type Rep GetMetricData :: Type -> Type #

NFData GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Methods

rnf :: GetMetricData -> () #

Hashable GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

AWSPager GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

AWSRequest GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Associated Types

type AWSResponse GetMetricData #

ToHeaders GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

ToPath GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

ToQuery GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

type Rep GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

type AWSResponse GetMetricData Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

newGetMetricData Source #

Create a value of GetMetricData with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:maxDatapoints:GetMetricData', getMetricData_maxDatapoints - The maximum number of data points the request should return before paginating. If you omit this, the default of 100,800 is used.

$sel:labelOptions:GetMetricData', getMetricData_labelOptions - This structure includes the Timezone parameter, which you can use to specify your time zone so that the labels of returned data display the correct time for your time zone.

$sel:nextToken:GetMetricData', getMetricData_nextToken - Include this value, if it was returned by the previous GetMetricData operation, to get the next set of data points.

$sel:scanBy:GetMetricData', getMetricData_scanBy - The order in which data points should be returned. TimestampDescending returns the newest data first and paginates when the MaxDatapoints limit is reached. TimestampAscending returns the oldest data first and paginates when the MaxDatapoints limit is reached.

$sel:metricDataQueries:GetMetricData', getMetricData_metricDataQueries - The metric queries to be returned. A single GetMetricData call can include as many as 500 MetricDataQuery structures. Each of these structures can specify either a metric to retrieve, or a math expression to perform on retrieved data.

$sel:startTime:GetMetricData', getMetricData_startTime - The time stamp indicating the earliest data to be returned.

The value specified is inclusive; results include data points with the specified time stamp.

CloudWatch rounds the specified time stamp as follows:

  • Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded down to 12:32:00.
  • Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, 12:32:34 is rounded down to 12:30:00.
  • Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, 12:32:34 is rounded down to 12:00:00.

If you set Period to 5, 10, or 30, the start time of your request is rounded down to the nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15.

For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as StartTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the StartTime.

$sel:endTime:GetMetricData', getMetricData_endTime - The time stamp indicating the latest data to be returned.

The value specified is exclusive; results include data points up to the specified time stamp.

For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as EndTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the EndTime.

Request Lenses

getMetricData_maxDatapoints :: Lens' GetMetricData (Maybe Int) Source #

The maximum number of data points the request should return before paginating. If you omit this, the default of 100,800 is used.

getMetricData_labelOptions :: Lens' GetMetricData (Maybe LabelOptions) Source #

This structure includes the Timezone parameter, which you can use to specify your time zone so that the labels of returned data display the correct time for your time zone.

getMetricData_nextToken :: Lens' GetMetricData (Maybe Text) Source #

Include this value, if it was returned by the previous GetMetricData operation, to get the next set of data points.

getMetricData_scanBy :: Lens' GetMetricData (Maybe ScanBy) Source #

The order in which data points should be returned. TimestampDescending returns the newest data first and paginates when the MaxDatapoints limit is reached. TimestampAscending returns the oldest data first and paginates when the MaxDatapoints limit is reached.

getMetricData_metricDataQueries :: Lens' GetMetricData [MetricDataQuery] Source #

The metric queries to be returned. A single GetMetricData call can include as many as 500 MetricDataQuery structures. Each of these structures can specify either a metric to retrieve, or a math expression to perform on retrieved data.

getMetricData_startTime :: Lens' GetMetricData UTCTime Source #

The time stamp indicating the earliest data to be returned.

The value specified is inclusive; results include data points with the specified time stamp.

CloudWatch rounds the specified time stamp as follows:

  • Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded down to 12:32:00.
  • Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, 12:32:34 is rounded down to 12:30:00.
  • Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, 12:32:34 is rounded down to 12:00:00.

If you set Period to 5, 10, or 30, the start time of your request is rounded down to the nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15.

For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as StartTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the StartTime.

getMetricData_endTime :: Lens' GetMetricData UTCTime Source #

The time stamp indicating the latest data to be returned.

The value specified is exclusive; results include data points up to the specified time stamp.

For better performance, specify StartTime and EndTime values that align with the value of the metric's Period and sync up with the beginning and end of an hour. For example, if the Period of a metric is 5 minutes, specifying 12:05 or 12:30 as EndTime can get a faster response from CloudWatch than setting 12:07 or 12:29 as the EndTime.

Destructuring the Response

data GetMetricDataResponse Source #

See: newGetMetricDataResponse smart constructor.

Constructors

GetMetricDataResponse' 

Fields

  • metricDataResults :: Maybe [MetricDataResult]

    The metrics that are returned, including the metric name, namespace, and dimensions.

  • nextToken :: Maybe Text

    A token that marks the next batch of returned results.

  • messages :: Maybe [MessageData]

    Contains a message about this GetMetricData operation, if the operation results in such a message. An example of a message that might be returned is Maximum number of allowed metrics exceeded. If there is a message, as much of the operation as possible is still executed.

    A message appears here only if it is related to the global GetMetricData operation. Any message about a specific metric returned by the operation appears in the MetricDataResult object returned for that metric.

  • httpStatus :: Int

    The response's http status code.

Instances

Instances details
Eq GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Read GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Show GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Generic GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Associated Types

type Rep GetMetricDataResponse :: Type -> Type #

NFData GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

Methods

rnf :: GetMetricDataResponse -> () #

type Rep GetMetricDataResponse Source # 
Instance details

Defined in Amazonka.CloudWatch.GetMetricData

type Rep GetMetricDataResponse = D1 ('MetaData "GetMetricDataResponse" "Amazonka.CloudWatch.GetMetricData" "libZSservicesZSamazonka-cloudwatchZSamazonka-cloudwatch" 'False) (C1 ('MetaCons "GetMetricDataResponse'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "metricDataResults") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [MetricDataResult])) :*: S1 ('MetaSel ('Just "nextToken") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "messages") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [MessageData])) :*: S1 ('MetaSel ('Just "httpStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))))

newGetMetricDataResponse Source #

Create a value of GetMetricDataResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:metricDataResults:GetMetricDataResponse', getMetricDataResponse_metricDataResults - The metrics that are returned, including the metric name, namespace, and dimensions.

$sel:nextToken:GetMetricData', getMetricDataResponse_nextToken - A token that marks the next batch of returned results.

$sel:messages:GetMetricDataResponse', getMetricDataResponse_messages - Contains a message about this GetMetricData operation, if the operation results in such a message. An example of a message that might be returned is Maximum number of allowed metrics exceeded. If there is a message, as much of the operation as possible is still executed.

A message appears here only if it is related to the global GetMetricData operation. Any message about a specific metric returned by the operation appears in the MetricDataResult object returned for that metric.

$sel:httpStatus:GetMetricDataResponse', getMetricDataResponse_httpStatus - The response's http status code.

Response Lenses

getMetricDataResponse_metricDataResults :: Lens' GetMetricDataResponse (Maybe [MetricDataResult]) Source #

The metrics that are returned, including the metric name, namespace, and dimensions.

getMetricDataResponse_nextToken :: Lens' GetMetricDataResponse (Maybe Text) Source #

A token that marks the next batch of returned results.

getMetricDataResponse_messages :: Lens' GetMetricDataResponse (Maybe [MessageData]) Source #

Contains a message about this GetMetricData operation, if the operation results in such a message. An example of a message that might be returned is Maximum number of allowed metrics exceeded. If there is a message, as much of the operation as possible is still executed.

A message appears here only if it is related to the global GetMetricData operation. Any message about a specific metric returned by the operation appears in the MetricDataResult object returned for that metric.