Skip to content

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.

// init — grants cloudwatch:GetMetricWidgetImage
const getMetricWidgetImage = yield* AWS.CloudWatch.GetMetricWidgetImage();
// runtime
const result = yield* getMetricWidgetImage({
MetricWidget: JSON.stringify({
metrics: [["MyApp/Payments", "PaymentProcessed"]],
width: 600,
height: 400,
start: "-PT3H",
}),
});
const png = result.MetricWidgetImage; // image bytes