Created
May 14, 2018 13:24
-
-
Save anaynayak/8c70df12a1d776999324c817e903403c to your computer and use it in GitHub Desktop.
Create Provisioned Capacity v/s Consumed Capacity dashboard in AWS Cloudwatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
readline = require('readline'); | |
var filePath = process.argv[2] | |
if (!filePath) { | |
console.error("node dynamo.js /path/to/file") | |
process.exit(1) | |
} | |
var rd = readline.createInterface({ | |
input: fs.createReadStream(filePath), | |
console: false | |
}); | |
var widgets = []; | |
function renderWidget(x, y, table, metric) { | |
return { | |
"type": "metric", | |
"x": x, | |
"y": y, | |
"width": 6, | |
"height": 6, | |
"styles": "undefined", | |
"properties": { | |
"view": "timeSeries", | |
"stacked": false, | |
"metrics": [ | |
[{ | |
"expression": `m1${metric}ConsumedReadCapacityUnits / 300`, | |
"label": `Consumed ReadCapacityUnits`, | |
"id": `e1${metric}ConsumedReadCapacityUnits`, | |
"stat": "Sum", | |
"period": 60 | |
}], | |
["AWS/DynamoDB", "ConsumedReadCapacityUnits", "TableName", `${table}`, { "id": `m1${metric}ConsumedReadCapacityUnits`, "stat": "Sum", "period": 300, "visible": false }], | |
[".", "ProvisionedReadCapacityUnits", ".", ".", { "id": `m1${metric}ProvisionedReadCapacityUnits`, "stat": "Sum", "period": 300 }] | |
], | |
"region": "ap-southeast-1", | |
"title": `${table}` | |
} | |
}; | |
} | |
rd.on('line', function (table) { | |
var metric = table.replace(/\./g, '') | |
widgets.push(renderWidget((6 * widgets.length) % 24, 6 * widgets.length, table, metric)); | |
}); | |
rd.on('close', function () { | |
console.log(JSON.stringify({ widgets: widgets })); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment