How to create CloudWatch dashboard
Let’s say we have an ALB, 2 namespaces and 1 running application in per namespace.
We wan’t to create a dashboard, named “Dev”.
Here is my code:
locals {
load_balancer_custom = split("loadbalancer/", data.aws_lb.load_balancer_arn.arn)[1]
cluster_name = "dev"
namespace_1 = "test"
namespace_2 = "qa"
}
data "aws_lb" "load_balancer_arn" {
name = "alb-dev"
}
module "monitoring_dashboard" {
source = "dasmeta/monitoring/aws//modules/dashboard"
version = "1.2.3"
name = "Dev"
rows = [
// This part is for Load Balancer
[
{
type : "text/title"
text : "Requests"
}
],
[
{
type : "balancer/2xx",
balancer_arn : data.aws_lb.load_balancer_arn.arn
},
{
type : "balancer/4xx",
balancer_arn : data.aws_lb.load_balancer_arn.arn
},
{
type : "balancer/5xx",
balancer_arn : data.aws_lb.load_balancer_arn.arn
},
{
type = "custom",
title = "Response Time + Volume",
metrics : [
{
MetricNamespace = "AWS/ApplicationELB"
MetricName = "ProcessedBytes"
LoadBalancer = local.load_balancer_custom
},
{
MetricNamespace = "AWS/ApplicationELB"
MetricName = "TargetResponseTime"
LoadBalancer = local.load_balancer_custom
}
]
}
],
//This is for 1-st application in namespace "test"
[
{
type : "text/title"
text : "Test"
}
],
[
{
type : "container/cpu",
period : 300,
container : "application_1",
cluster : local.cluster_name,
namespace : local.namespace_1
},
{
type : "container/memory",
period : 300,
container : "application_1",
cluster : local.cluster_name,
namespace : local.namespace_1
},
{
type : "container/network",
period : 300,
container : "application_1",
cluster : local.cluster_name,
namespace : local.namespace_1
},
{
type : "container/restarts",
period : 300,
container : "application_1",
cluster : local.cluster_name,
namespace : local.namespace_1
},
],
//And this is for 2-nd application in namespace "qa"
[
{
type : "text/title"
text : "QA"
}
],
[
{
type : "container/cpu",
period : 300,
container : "application_2",
cluster : local.cluster_name,
namespace : local.namespace_2
},
{
type : "container/memory",
period : 300,
container : "application_2",
cluster : local.cluster_name,
namespace : local.namespace_2
},
{
type : "container/network",
period : 300,
container : "application_2",
cluster : local.cluster_name,
namespace : local.namespace_2
},
{
type : "container/restarts",
period : 300,
container : "application_2",
cluster : local.cluster_name,
namespace : local.namespace_2
},
],
]
}
Dashboard with RDS / Postgresql widget
locals = {
db_instance_identifier = "dev-db"
}
module "monitoring_dashboard" {
source = "dasmeta/monitoring/aws//modules/dashboard"
version = "1.2.3"
name = "Dev-RDS"
rows = [
[
{
type : "text/title"
text : "RDS / PostgreSQL"
}
],
[
{
type : "custom",
title : "Main Units",
height : 5
width : 12
metrics : [
{
MetricNamespace = "AWS/RDS"
MetricName = "CPUUtilization"
DBInstanceIdentifier = local.db_instance_identifier
},
{
MetricNamespace = "AWS/RDS"
MetricName = "FreeableMemory"
DBInstanceIdentifier = local.db_instance_identifier
},
{
MetricNamespace = "AWS/RDS"
MetricName = "FreeStorageSpace"
DBInstanceIdentifier = local.db_instance_identifier
},
{
MetricNamespace = "AWS/RDS"
MetricName = "DatabaseConnections"
DBInstanceIdentifier = local.db_instance_identifier
}
]
},
]
]
}
Dashboard with RabbitMQ widget
locals = {
broker_name = "dev-broker"
}
module "monitoring_dashboard" {
source = "dasmeta/monitoring/aws//modules/dashboard"
version = "1.2.3"
name = "Dev-MQ"
rows = [
[
{
type : "text/title"
text : "RabbitMQ"
}
],
[
{
type : "custom",
title : "Main Units",
height : 5
width : 12
metrics : [
{
MetricNamespace = "AWS/AmazonMQ"
MetricName = "MessageCount"
Broker = local.broker_name
},
{
MetricNamespace = "AWS/AmazonMQ"
MetricName = "ConsumerCount"
Broker = local.broker_name
},
{
MetricNamespace = "AWS/AmazonMQ"
MetricName = "PublishRate"
Broker = local.broker_name
},
{
MetricNamespace = "AWS/AmazonMQ"
MetricName = "AckRate"
Broker = local.broker_name
},
]
},
],
]
}
, multiple selections available,
Related content
How to configure Log Based Metrics
How to configure Log Based Metrics
More like this
AWS CloudWatch Usage Guide
AWS CloudWatch Usage Guide
More like this