Skip to content

Commit

Permalink
fix: only show metrics for the deployed database (#329)
Browse files Browse the repository at this point in the history
* fix: only show metrics for the deployed database

* fix: unused var
  • Loading branch information
chris13524 authored Jan 23, 2024
1 parent 91469fc commit 21ca495
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions terraform/monitoring/dashboard.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local vars = {

ecs_service_name: std.extVar('ecs_service_name'),
ecs_cluster_name: std.extVar('ecs_cluster_name'),
rds_cluster_id: std.extVar('rds_cluster_id'),
redis_cluster_id: std.extVar('redis_cluster_id'),
load_balancer: std.extVar('load_balancer'),
target_group: std.extVar('target_group'),
Expand Down
1 change: 1 addition & 0 deletions terraform/monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data "jsonnet_file" "dashboard" {

ecs_cluster_name = var.ecs_cluster_name
ecs_service_name = var.ecs_service_name
rds_cluster_id = var.rds_cluster_id
redis_cluster_id = var.redis_cluster_id
load_balancer = var.load_balancer_arn
target_group = var.ecs_target_group_arn
Expand Down
4 changes: 4 additions & 0 deletions terraform/monitoring/panels/rds/cpu.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ local targets = grafana.targets;
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'CPUUtilization',
dimensions = {
DBClusterIdentifier: vars.rds_cluster_id,
},
matchExact = true,
statistic = 'Average',
refId = 'CPU_Avg'
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ local targets = grafana.targets;
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'DatabaseConnections',
dimensions = {
DBClusterIdentifier: vars.rds_cluster_id,
},
matchExact = true,
statistic = 'Average',
))
}
4 changes: 4 additions & 0 deletions terraform/monitoring/panels/rds/freeable_memory.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ local targets = grafana.targets;
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'FreeableMemory',
dimensions = {
DBClusterIdentifier: vars.rds_cluster_id,
},
matchExact = true,
statistic = 'Average',
refId = 'Mem_Avg',
))
Expand Down
4 changes: 4 additions & 0 deletions terraform/monitoring/panels/rds/volume_bytes_used.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ local targets = grafana.targets;
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'VolumeBytesUsed',
dimensions = {
DBClusterIdentifier: vars.rds_cluster_id,
},
matchExact = true,
statistic = 'Average',
))
}
5 changes: 5 additions & 0 deletions terraform/monitoring/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ variable "ecs_target_group_arn" {
type = string
}

variable "rds_cluster_id" {
description = "The cluster ID of the RDS cluster."
type = string
}

variable "redis_cluster_id" {
description = "The cluster ID of the Redis cluster."
type = string
Expand Down
1 change: 1 addition & 0 deletions terraform/res_monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module "monitoring" {

ecs_cluster_name = module.ecs.ecs_cluster_name
ecs_service_name = module.ecs.ecs_service_name
rds_cluster_id = module.postgres.rds_cluster_id
ecs_target_group_arn = module.ecs.target_group_arn
redis_cluster_id = module.redis.cluster_id
load_balancer_arn = module.ecs.load_balancer_arn_suffix
Expand Down

0 comments on commit 21ca495

Please sign in to comment.