Skip to content
Snippets Groups Projects
Commit b0db4d3e authored by Edouard DE BRYE's avatar Edouard DE BRYE
Browse files

Added dashboard

parent 34619583
No related branches found
No related tags found
No related merge requests found
......@@ -37,3 +37,4 @@ terraform.rc
test/
**/node_modules/*
.vscode/
vegeta*
\ No newline at end of file
resource "aws_cloudwatch_dashboard" "main" {
dashboard_name = "${local.prefix}-main"
dashboard_body = templatefile("${path.module}/templates/dashboards/dashboard.json.tpl",
{
lambda_names = values(aws_lambda_function.crud)[*].function_name
dynamodb_table_name = aws_dynamodb_table.main.name
apigw_stage_name = aws_api_gateway_stage.main.stage_name
apigw_name = aws_api_gateway_rest_api.main.name
aws_region = var.aws_region
})
}
output "dashboard_json" {
value = aws_cloudwatch_dashboard.main.dashboard_body
}
\ No newline at end of file
{
"widgets": [
{
"height": 3,
"width": 24,
"y": 0,
"x": 0,
"type": "text",
"properties": {
"markdown": "\n# API Gateway\n"
}
},
{
"height": 3,
"width": 24,
"y": 15,
"x": 0,
"type": "text",
"properties": {
"markdown": "\n# Lambdas\n"
}
},
{
"height": 3,
"width": 24,
"y": 29,
"x": 0,
"type": "text",
"properties": {
"markdown": "\n# DynamoDB\n"
}
},
{
"height": 6,
"width": 12,
"y": 3,
"x": 0,
"type": "metric",
"properties": {
"metrics": [
[ { "expression": "100*(m1/m2)", "label": "Expression1", "id": "e1", "region": "eu-west-1" } ],
[ "AWS/ApiGateway", "4XXError", "ApiName", "${apigw_name}", "Stage", "${apigw_stage_name}", { "id": "m1", "visible": false } ],
[ ".", "Count", ".", ".", ".", ".", { "id": "m2", "visible": false } ]
],
"view": "timeSeries",
"stacked": false,
"region": "eu-west-1",
"period": 60,
"title": "Proportion of 4XX errors",
"stat": "Sum"
}
},
{
"height": 6,
"width": 12,
"y": 3,
"x": 12,
"type": "metric",
"properties": {
"metrics": [
[ { "expression": "100*(m1/m2)", "label": "Expression1", "id": "e1", "region": "eu-west-1" } ],
[ "AWS/ApiGateway", "5XXError", "ApiName", "${apigw_name}", "Stage", "${apigw_stage_name}", { "id": "m1", "visible": false } ],
[ ".", "Count", ".", ".", ".", ".", { "id": "m2", "visible": false } ]
],
"view": "timeSeries",
"stacked": false,
"region": "eu-west-1",
"period": 60,
"title": "Proportion of 5XX errors",
"stat": "Sum"
}
},
{
"height": 6,
"width": 12,
"y": 9,
"x": 0,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ "AWS/ApiGateway", "Count", "ApiName", "${apigw_name}", "Stage", "${apigw_stage_name}" ]
],
"region": "${aws_region}",
"title":"Number of requests",
"period": 60,
"stat":"Sum"
}
},
{
"height": 6,
"width": 12,
"y": 18,
"x": 0,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": ${jsonencode(
[
for name in lambda_names : ["AWS/Lambda", "Throttles", "FunctionName", "${name}"]
])
},
"region": "${aws_region}",
"period": 60
}
},
{
"height": 6,
"width": 12,
"y": 18,
"x": 12,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": ${jsonencode(
[
for name in lambda_names : ["AWS/Lambda", "Invocations", "FunctionName", "${name}"]
])
},
"region": "${aws_region}",
"period": 60
}
},
{
"height": 6,
"width": 12,
"y": 24,
"x": 0,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": ${jsonencode(
[
for name in lambda_names : ["LambdaInsights", "memory_utilization", "function_name", "${name}"]
])
},
"region": "${aws_region}",
"period":60
}
},
{
"height": 6,
"width": 12,
"y": 33,
"x": 0,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ "AWS/DynamoDB", "ConsumedWriteCapacityUnits", "TableName", "${dynamodb_table_name}" ],
[ ".", "ProvisionedWriteCapacityUnits", ".", "." ]
],
"region": "${aws_region}",
"period":60
}
},
{
"height": 6,
"width": 12,
"y": 33,
"x": 12,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ "AWS/DynamoDB", "ConsumedReadCapacityUnits", "TableName", "${dynamodb_table_name}" ],
[ ".", "ProvisionedWriteCapacityUnits", ".", "." ]
],
"region": "${aws_region}",
"period": 60
}
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment