the AWS SDK documentation (https://docs.amazonaws.cn/en_us/AmazonCloudWatch/latest/APIReference/API_MetricDataResult.html) provides a small hint about missing NextToken - if a metric math expression has been specified within a query, the NextToken will not be returned.

But at the same time, it also state that if we do request a huge data volume and an incomplete set of data points were returned, the status code will be to PartialData and the NextToken value will be returned thus allowing us to repeat request(s) to get more data points.

The query can't be processed anymore because the NextToken is missing...

What to do if you are performing a metric math expression, status code is shown as Partial Data, but the NextToken is not returned (missing)?

1

There are 1 best solutions below

0
R0B0T-B0BA On

Apparently the hint about math expression takes absolute precedence over PartialData status code, thus leading to missing NextToken. In other words, if you have huge amount of metric data and a math expression, you have to ensure that all data will be returned in one round-trip without pagination.

Whenever possible, follow the practices to avoid pagination (PartialData status) to solve the challenge:

1) Review your code to avoid any data points limitation - consider using the default value.

By default, data points are limited to 100800 ones in total (https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html).
Limiting the data points may leads to pagination, thus leading to PartialData.

2) Try to reduce the number of requested metrics

3) Reduce the time frame (keep StartTime and EndTime close to each other) for your query to reduce the # of data points.

4) If you can't reduce the time frame, try to increase a metric's Period to higher value - for instance, 1 hour instead of 5 mins. It will aggregate the result by reducing the number of data points.

Good luck!