Are earlier historical metrics published to CloudWatch Delayed?

672 views Asked by At

I've got a custom CloudWatch metric based on a historical value, so I'm publishing them with explicit timestamps. I've seen an issue using both the C# and PowerShell APIs where I don't see all my metrics right away.

In the example below, I'm creating sample points for every hour for the past two weeks, but I only see the last ~48 hours in my graph in the CloudWatch console.

Initialize-AWSDefaults

$cwNamespace = 'Historical CW Sanity Check'
# generate some data 
$now = [DateTime]::Now.ToUniversalTime()

$startTime = $now - [TimeSpan]::FromDays(14)

$t = $startTime
$x = 0

while ($t -le $now)
{

    $t += [TimeSpan]::FromHours(1)

    $datum = New-Object -TypeName 'Amazon.CloudWatch.Model.MetricDatum'

    $datum.Unit = [Amazon.CloudWatch.StandardUnit]::Count
    $datum.Value = 2 * $x
    $datum.Timestamp = $t
    $datum.MetricName = 'Test 2'

    $x +=1.0
    Write-Host "($t, $x)"
    Write-CWMetricData -Namespace $cwNamespace -MetricData $datum

}

Current plot for this metric.

From the docs, I thought it supported up to two weeks' worth of historical data. I'm wondering why I see the new points before the old points (or if the old points are going to show up at all). It looks like I'm only getting two days' worth.

1

There are 1 answers

0
Jay Carlton On BEST ANSWER

From the help text on Write-CWMetricData:

Data that is timestamped 24 hours or more in the past may
take in excess of 48 hours to become available from submission time using 
GetMetricStatistics.

I'm betting the same limit holds true for the graphs in the Console.