Skip to content

Commit

Permalink
feat: RDS Grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Oct 28, 2023
1 parent a0a4255 commit b693e9a
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
7 changes: 7 additions & 0 deletions terraform/monitoring/dashboard.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ dashboard.new(
panels.ecs.cpu(ds, vars) { gridPos: pos._2 },
panels.ecs.memory(ds, vars) { gridPos: pos._2 },

//////////////////////////////////////////////////////////////////////////////
row.new('RDS'),
panels.rds.cpu(ds, vars) { gridPos: pos._4 },
panels.rds.freeable_memory(ds, vars) { gridPos: pos._4 },
panels.rds.volume_bytes_used(ds, vars) { gridPos: pos._4 },
panels.rds.database_connections(ds, vars) { gridPos: pos._4 },

//////////////////////////////////////////////////////////////////////////////
row.new('DocumentDB'),
panels.db.available_memory(ds, vars) { gridPos: pos._3 },
Expand Down
14 changes: 10 additions & 4 deletions terraform/monitoring/panels/panels.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ local docdb_mem_threshold = units.size_bin(GiB = docdb_mem * 0.1);
http_requests: (import 'app/http_requests.libsonnet' ).new,
http_request_latency: (import 'app/http_request_latency.libsonnet' ).new,
},
ecs: {
cpu(ds, vars): ecs.cpu.panel(ds.cloudwatch, vars.namespace, vars.environment, vars.notifications, vars.ecs_service_name, vars.ecs_cluster_name),
memory(ds, vars): ecs.memory.panel(ds.cloudwatch, vars.namespace, vars.environment, vars.notifications, vars.ecs_service_name, vars.ecs_cluster_name),
},
rds: {
cpu(ds, vars): (import 'rds/cpu.libsonnet' ).new,
freeable_memory(ds, vars): (import 'rds/freeable_memory.libsonnet' ).new,
volume_bytes_used(ds, vars): (import 'rds/volume_bytes_used.libsonnet' ).new,
database_connections(ds, vars): (import 'rds/database_connections.libsonnet' ).new,
},
db: {
available_memory(ds, vars): docdb.available_memory.panel(ds.cloudwatch, vars.namespace, vars.environment, vars.notifications, vars.docdb_cluster_id, mem_threshold = docdb_mem_threshold),
buffer_cache_hit_ratio(ds, vars): docdb.buffer_cache_hit_ratio.panel(ds.cloudwatch, vars.docdb_cluster_id),
Expand All @@ -31,10 +41,6 @@ local docdb_mem_threshold = units.size_bin(GiB = docdb_mem * 0.1);
volume(ds, vars): docdb.volume.panel(ds.cloudwatch, vars.docdb_cluster_id),
write_latency(ds, vars): docdb.write_latency.panel(ds.cloudwatch, vars.docdb_cluster_id),
},
ecs: {
cpu(ds, vars): ecs.cpu.panel(ds.cloudwatch, vars.namespace, vars.environment, vars.notifications, vars.ecs_service_name, vars.ecs_cluster_name),
memory(ds, vars): ecs.memory.panel(ds.cloudwatch, vars.namespace, vars.environment, vars.notifications, vars.ecs_service_name, vars.ecs_cluster_name),
},
lb: {
active_connections: (import 'lb/active_connections.libsonnet' ).new,
error_4xx: (import 'lb/error_4xx.libsonnet' ).new,
Expand Down
21 changes: 21 additions & 0 deletions terraform/monitoring/panels/rds/cpu.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local grafana = import '../../grafonnet-lib/grafana.libsonnet';
local defaults = import '../../grafonnet-lib/defaults.libsonnet';

local panels = grafana.panels;
local targets = grafana.targets;

{
new(ds, vars)::
panels.timeseries(
title = 'CPU',
datasource = ds.cloudwatch,
)
.configure(defaults.configuration.timeseries)

.addTarget(targets.cloudwatch(
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'CPUUtilization',
statistics = 'Average',
))
}
21 changes: 21 additions & 0 deletions terraform/monitoring/panels/rds/database_connections.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local grafana = import '../../grafonnet-lib/grafana.libsonnet';
local defaults = import '../../grafonnet-lib/defaults.libsonnet';

local panels = grafana.panels;
local targets = grafana.targets;

{
new(ds, vars)::
panels.timeseries(
title = 'Connections',
datasource = ds.cloudwatch,
)
.configure(defaults.configuration.timeseries)

.addTarget(targets.cloudwatch(
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'DatabaseConnections',
statistics = 'Average',
))
}
24 changes: 24 additions & 0 deletions terraform/monitoring/panels/rds/freeable_memory.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local grafana = import '../../grafonnet-lib/grafana.libsonnet';
local defaults = import '../../grafonnet-lib/defaults.libsonnet';

local panels = grafana.panels;
local targets = grafana.targets;

{
new(ds, vars)::
panels.timeseries(
title = 'Freeable Memory',
datasource = ds.cloudwatch,
)
.configure(
defaults.configuration.timeseries
.withUnit(grafana.fieldConfig.units.DecBytes)
)

.addTarget(targets.cloudwatch(
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'FreeableMemory',
statistics = 'Average',
))
}
24 changes: 24 additions & 0 deletions terraform/monitoring/panels/rds/volume_bytes_used.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local grafana = import '../../grafonnet-lib/grafana.libsonnet';
local defaults = import '../../grafonnet-lib/defaults.libsonnet';

local panels = grafana.panels;
local targets = grafana.targets;

{
new(ds, vars)::
panels.timeseries(
title = 'Volume Used',
datasource = ds.cloudwatch,
)
.configure(
defaults.configuration.timeseries
.withUnit(grafana.fieldConfig.units.DecBytes)
)

.addTarget(targets.cloudwatch(
datasource = ds.cloudwatch,
namespace = 'AWS/RDS',
metricName = 'VolumeBytesUsed',
statistics = 'Average',
))
}

0 comments on commit b693e9a

Please sign in to comment.