millions-furniture-75402
03/05/2021, 4:44 PM{
"widgets": [
{
"type": "alarm",
"x": 0,
"y": 0,
"width": 24,
"height": 3,
"properties": {
"title": "",
"alarms": [
"arn:aws:cloudwatch:us-east-2:0123456789:alarm:SystemBackupDuration-a2737a4",
]
}
}
]
}
purple-jelly-68780
03/05/2021, 4:57 PMmillions-furniture-75402
03/05/2021, 5:00 PMfaint-table-42725
03/05/2021, 5:01 PMdashboardBody
property on the Dashboard
resource you pass a JSON object to.millions-furniture-75402
03/05/2021, 5:03 PMawsx.cloudwatch.AlarmWidget
which I think is what I need.faint-table-42725
03/05/2021, 5:05 PMawsx
perspective.millions-furniture-75402
03/05/2021, 5:06 PMconst dashboardName = `${appName}-${aws.config.region}`;
new awsx.cloudwatch.Dashboard(dashboardName, {
widgets: [
// EC2 / bastion
new awsx.cloudwatch.TextWidget({
markdown: "# Bastion",
height: 1,
width: 24,
}),
new awsx.cloudwatch.LineGraphMetricWidget({
title: "CPU Utilization",
width: 6,
height: 3,
annotations: new awsx.cloudwatch.HorizontalAnnotation(bastionAlarms.cpuUtilization),
metrics: bastionMetrics.cpuUtilization,
}),
new awsx.cloudwatch.LineGraphMetricWidget({
title: "Network",
width: 6,
height: 3,
metrics: [
bastionMetrics.networkIn,
bastionMetrics.networkOut,
],
}),
],
});
new awsx.cloudwatch.AlarmWidget({
width: 24,
height: 3,
alarms: [
bastionMetrics.cpuUtilization
],
}),
faint-table-42725
03/05/2021, 5:08 PMawsx
library as https://github.com/pulumi/pulumi-awsx/blob/bf6ce7cbab4ec1d6d991bc85ae320f5a3839b0f0/nodejs/awsx/cloudwatch/widgets_json.ts#L24millions-furniture-75402
03/05/2021, 5:09 PMaddWidgetJson
method maybefaint-table-42725
03/05/2021, 5:12 PMWidgetJson
which restricts the type
to metric
and text
alarm
🙂millions-furniture-75402
03/05/2021, 6:23 PMexport interface AlarmWidgetArgs extends awsx.cloudwatch.SimpleWidgetArgs {
alarms: pulumi.Input<string>[];
}
export interface WidgetJson {
type: pulumi.Input<"alarm" | "metric" | "text">;
x: pulumi.Input<number>;
y: pulumi.Input<number>;
width: pulumi.Input<number>;
height: pulumi.Input<number>;
properties: Record<string, any>;
}
export class AlarmWidget implements awsx.cloudwatch.Widget {
private readonly alarms: pulumi.Input<string>[];
constructor(private readonly alarmArgs: AlarmWidgetArgs) {
this.alarms = alarmArgs.alarms;
}
public width() {
return this.alarmArgs.width !== undefined ? this.alarmArgs.width : 6;
}
public height() {
return this.alarmArgs.height !== undefined ? this.alarmArgs.height : 6;
}
/** For internal use only. */
public addWidgetJson(widgetJsons: WidgetJson[], xOffset: number, yOffset: number) {
// Build the structure common to all simple widgets. Defer to our subclasses for
// details only they can fill in.
widgetJsons.push({
x: xOffset,
y: yOffset,
width: this.width(),
height: this.height(),
type: "alarm",
properties: {
alarms: this.alarmArgs.alarms
},
});
}
}
Usage:
new AlarmWidget({
height: 3,
width: 24,
alarms: [
rdsAlarms.burstBalance.arn,
rdsAlarms.cpuCreditBalance.arn,
rdsAlarms.cpuUtilization.arn,
rdsAlarms.databaseConnections.arn,
rdsAlarms.diskQueueDepth.arn,
rdsAlarms.freeableMemory.arn,
rdsAlarms.freeStorageSpace.arn,
rdsAlarms.swapUsage.arn,
],
}),