GetMetricWidgetImage
Source:
src/AWS/CloudWatch/GetMetricWidgetImage.ts
Runtime binding for cloudwatch:GetMetricWidgetImage — render a metric
graph as a PNG (useful for embedding charts in alerts or reports).
Provide CloudWatch.GetMetricWidgetImageHttp on the hosting Lambda
Function to satisfy the requirement.
Rendering Metric Graphs
Section titled “Rendering Metric Graphs”// init — grants cloudwatch:GetMetricWidgetImageconst getMetricWidgetImage = yield* AWS.CloudWatch.GetMetricWidgetImage();
// runtimeconst result = yield* getMetricWidgetImage({ MetricWidget: JSON.stringify({ metrics: [["MyApp/Payments", "PaymentProcessed"]], width: 600, height: 400, start: "-PT3H", }),});const png = result.MetricWidgetImage; // image bytes