awslabs / pireporter

A comprehensive tool for capturing performance metrics and workload snapshots, and generating in-depth comparison reports for Amazon Aurora PostgreSQL databases. Helps to troubleshoot problems, optimize instance size and cost.
Apache License 2.0
10 stars 4 forks source link

Allow getting snapshots for periods where the CloudWatch Metrics aged out #10

Open alecl opened 1 month ago

alecl commented 1 month ago

I suspect a number of the Performance Insights CloudWatch Metrics are high-resolution ones that aren't available going further back compared to the rest of the snapshot data where I've configured a 31 day retention and can still get at it.

I'd rather have the snapshots without the CloudWatch Metrics that aren't unavailable rather than being blocked altogether.

  var cwData = await getCWMetrics(generalInformation)
  // Check if cloudWatch returns data
  if (cwData.MetricDataResults.find(v => v.Id === 'dbLoad').Values.length === 0) {
    console.log('No performance data available from CloudWatch for the selected timeframe. Please choose a timeframe with application load or user activity.')
    process.exit(1)
  }

I implemented something like this as a short-term workaround, though it's not ideal. It doesn't distinguish no data available from a true 0 value and could potentially confuse the compare report and AI analysis.

This would be a great official improvement that also is understood by the compare and AI analysis.

const handleNoPerformanceData = function() {
  console.warn('No performance data available from CloudWatch for the selected timeframe. Using default values.');
  return {
    MetricDataResults: [
      { Id: 'dbLoad', Values: [0] },
      { Id: 'auroraEstimatedSharedMemoryBytes', Values: [0] },
      { Id: 'networkThroughput', Values: [0] },
      { Id: 'storageNetworkThroughput', Values: [0] },
      { Id: 'writeThroughput', Values: [0] },
      { Id: 'engineUptime', Values: [0] },
      { Id: 'replicationSlotDiskUsage', Values: [0] },
      { Id: 'snapshotStorageUsed', Values: [0] },
      { Id: 'transactionLogsDiskUsage', Values: [0] },
      { Id: 'bufferCacheHitRatio', Values: [0] },
      { Id: 'volumeBytesUsed', Values: [0] }
    ]
  };
}
aychin-aws commented 1 month ago

Agree, very good observation. We need to think how we can improve it. I will also test your suggestion.