From b90515515edc82b5e04d50fb10dbbf2611fa0dc8 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 2 Feb 2024 14:57:22 -0500 Subject: [PATCH 1/5] fix: bump grafonnet-lib version --- terraform/monitoring/grafonnet-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/monitoring/grafonnet-lib b/terraform/monitoring/grafonnet-lib index 343c394..b085843 160000 --- a/terraform/monitoring/grafonnet-lib +++ b/terraform/monitoring/grafonnet-lib @@ -1 +1 @@ -Subproject commit 343c39494ec8f1561af5c158010dafc71fbb1351 +Subproject commit b085843dd64a0c8426f6f5cbd616fc1438379235 From 1a1340d3d09681d60940f222944f9a1633cdb50e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 2 Feb 2024 15:35:28 -0500 Subject: [PATCH 2/5] fix: remove defaults --- terraform/monitoring/panels/app/app_metric.libsonnet | 3 +-- terraform/monitoring/panels/defaults.libsonnet | 6 ------ terraform/monitoring/panels/docdb/cpu.libsonnet | 2 +- terraform/monitoring/panels/ecs/cpu.libsonnet | 2 +- terraform/monitoring/panels/ecs/memory.libsonnet | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/terraform/monitoring/panels/app/app_metric.libsonnet b/terraform/monitoring/panels/app/app_metric.libsonnet index 922172c..7184c26 100644 --- a/terraform/monitoring/panels/app/app_metric.libsonnet +++ b/terraform/monitoring/panels/app/app_metric.libsonnet @@ -1,9 +1,8 @@ local grafana = import '../../grafonnet-lib/grafana.libsonnet'; +local defaults = import '../../grafonnet-lib/defaults.libsonnet'; local panels = grafana.panels; local targets = grafana.targets; -local defaults = import '../defaults.libsonnet'; - { new(ds, vars, title, metric_name, metric_label):: panels.timeseries( diff --git a/terraform/monitoring/panels/defaults.libsonnet b/terraform/monitoring/panels/defaults.libsonnet index ab2a58d..1aad0b2 100644 --- a/terraform/monitoring/panels/defaults.libsonnet +++ b/terraform/monitoring/panels/defaults.libsonnet @@ -76,11 +76,5 @@ local grafana = import '../grafonnet-lib/grafana.libsonnet'; color : 'red', value : 50 }), - - timeseries_tr80:: self.timeseries - .addThreshold({ - color : 'red', - value : 80 - }), }, } diff --git a/terraform/monitoring/panels/docdb/cpu.libsonnet b/terraform/monitoring/panels/docdb/cpu.libsonnet index 7815cb1..f8c6df3 100644 --- a/terraform/monitoring/panels/docdb/cpu.libsonnet +++ b/terraform/monitoring/panels/docdb/cpu.libsonnet @@ -32,7 +32,7 @@ local cpu_alert(vars) = alert.new( title = 'CPU Utilization', datasource = ds.cloudwatch, ) - .configure(defaults.configuration.timeseries_resource) + .configure(defaults.configuration.timeseries) .setAlert(cpu_alert(vars)) .addTarget(targets.cloudwatch( diff --git a/terraform/monitoring/panels/ecs/cpu.libsonnet b/terraform/monitoring/panels/ecs/cpu.libsonnet index 22ae5b0..0713c93 100644 --- a/terraform/monitoring/panels/ecs/cpu.libsonnet +++ b/terraform/monitoring/panels/ecs/cpu.libsonnet @@ -11,7 +11,7 @@ local overrides = defaults.overrides; title = 'CPU Utilization', datasource = ds.cloudwatch, ) - .configure(overrides.cpu(defaults.configuration.timeseries_resource)) + .configure(overrides.cpu(defaults.configuration.timeseries)) .setAlert(defaults.alerts.cpu( namespace = vars.namespace, title = 'ECS', diff --git a/terraform/monitoring/panels/ecs/memory.libsonnet b/terraform/monitoring/panels/ecs/memory.libsonnet index 045f0b0..cbe88fd 100644 --- a/terraform/monitoring/panels/ecs/memory.libsonnet +++ b/terraform/monitoring/panels/ecs/memory.libsonnet @@ -10,7 +10,7 @@ local targets = grafana.targets; title = 'Memory Utilization', datasource = ds.cloudwatch, ) - .configure(defaults.overrides.memory(defaults.configuration.timeseries_resource)) + .configure(defaults.overrides.memory(defaults.configuration.timeseries)) .setAlert(defaults.alerts.memory( namespace = vars.namespace, From d9ef9e8d6d238d317d230a4c387e693c0da47bd9 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 2 Feb 2024 15:47:16 -0500 Subject: [PATCH 3/5] fix: add environment to alert --- .../panels/docdb/available_memory.libsonnet | 5 ++++- terraform/monitoring/panels/docdb/cpu.libsonnet | 5 ++++- .../panels/docdb/low_mem_op_throttled.libsonnet | 5 ++++- terraform/monitoring/panels/ecs/cpu.libsonnet | 15 +++++++++------ terraform/monitoring/panels/ecs/memory.libsonnet | 15 +++++++++------ .../monitoring/panels/lb/error_5xx.libsonnet | 1 + 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/terraform/monitoring/panels/docdb/available_memory.libsonnet b/terraform/monitoring/panels/docdb/available_memory.libsonnet index 5981723..7dd653a 100644 --- a/terraform/monitoring/panels/docdb/available_memory.libsonnet +++ b/terraform/monitoring/panels/docdb/available_memory.libsonnet @@ -76,7 +76,10 @@ local mem_alert(vars) = alert.new( value = mem_threshold, ) - .setAlert(mem_alert(vars)) + .setAlert( + vars.environment, + mem_alert(vars) + ) .addTarget(targets.cloudwatch( refId = 'Mem_Min', diff --git a/terraform/monitoring/panels/docdb/cpu.libsonnet b/terraform/monitoring/panels/docdb/cpu.libsonnet index f8c6df3..6fa6803 100644 --- a/terraform/monitoring/panels/docdb/cpu.libsonnet +++ b/terraform/monitoring/panels/docdb/cpu.libsonnet @@ -33,7 +33,10 @@ local cpu_alert(vars) = alert.new( datasource = ds.cloudwatch, ) .configure(defaults.configuration.timeseries) - .setAlert(cpu_alert(vars)) + .setAlert( + vars.environment, + cpu_alert(vars) + ) .addTarget(targets.cloudwatch( refId = 'CPU_Max', diff --git a/terraform/monitoring/panels/docdb/low_mem_op_throttled.libsonnet b/terraform/monitoring/panels/docdb/low_mem_op_throttled.libsonnet index 7ea7d99..2f6702b 100644 --- a/terraform/monitoring/panels/docdb/low_mem_op_throttled.libsonnet +++ b/terraform/monitoring/panels/docdb/low_mem_op_throttled.libsonnet @@ -58,7 +58,10 @@ local ops_alert(vars) = alert.new( ) .configure(_configuration) - .setAlert(ops_alert(vars)) + .setAlert( + vars.environment, + ops_alert(vars) + ) .addTarget(targets.cloudwatch( alias = 'LowMem Num Operations Throttled (Max)', diff --git a/terraform/monitoring/panels/ecs/cpu.libsonnet b/terraform/monitoring/panels/ecs/cpu.libsonnet index 0713c93..cf0a12a 100644 --- a/terraform/monitoring/panels/ecs/cpu.libsonnet +++ b/terraform/monitoring/panels/ecs/cpu.libsonnet @@ -12,12 +12,15 @@ local overrides = defaults.overrides; datasource = ds.cloudwatch, ) .configure(overrides.cpu(defaults.configuration.timeseries)) - .setAlert(defaults.alerts.cpu( - namespace = vars.namespace, - title = 'ECS', - env = vars.environment, - notifications = vars.notifications, - )) + .setAlert( + vars.environment, + defaults.alerts.cpu( + namespace = vars.namespace, + title = 'ECS', + env = vars.environment, + notifications = vars.notifications, + ) + ) .addTarget(targets.cloudwatch( alias = 'CPU (Max)', diff --git a/terraform/monitoring/panels/ecs/memory.libsonnet b/terraform/monitoring/panels/ecs/memory.libsonnet index cbe88fd..067de7d 100644 --- a/terraform/monitoring/panels/ecs/memory.libsonnet +++ b/terraform/monitoring/panels/ecs/memory.libsonnet @@ -12,12 +12,15 @@ local targets = grafana.targets; ) .configure(defaults.overrides.memory(defaults.configuration.timeseries)) - .setAlert(defaults.alerts.memory( - namespace = vars.namespace, - title = 'ECS', - env = vars.environment, - notifications = vars.notifications, - )) + .setAlert( + vars.environment, + defaults.alerts.memory( + namespace = vars.namespace, + title = 'ECS', + env = vars.environment, + notifications = vars.notifications, + ) + ) .addTarget(targets.cloudwatch( alias = 'Memory (Max)', diff --git a/terraform/monitoring/panels/lb/error_5xx.libsonnet b/terraform/monitoring/panels/lb/error_5xx.libsonnet index 3c9ca3b..2a8412d 100644 --- a/terraform/monitoring/panels/lb/error_5xx.libsonnet +++ b/terraform/monitoring/panels/lb/error_5xx.libsonnet @@ -30,6 +30,7 @@ local _configuration = defaults.configuration.timeseries ) .setAlert( + vars.environment, grafana.alert.new( namespace = vars.namespace, name = "%(env)s - 5XX alert" % { env: grafana.utils.strings.capitalize(vars.environment) }, From c6bbc9ebb83afc374ce97c953d7c6427a3a26209 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 2 Feb 2024 15:58:25 -0500 Subject: [PATCH 4/5] fix: metricQueryTypes --- terraform/monitoring/panels/lb/healthy_hosts.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/monitoring/panels/lb/healthy_hosts.libsonnet b/terraform/monitoring/panels/lb/healthy_hosts.libsonnet index 67c9952..91f191f 100644 --- a/terraform/monitoring/panels/lb/healthy_hosts.libsonnet +++ b/terraform/monitoring/panels/lb/healthy_hosts.libsonnet @@ -20,7 +20,7 @@ local _configuration = defaults.configuration.timeseries .addTarget(targets.cloudwatch( datasource = ds.cloudwatch, - metricQueryType = grafana.target.cloudwatch.metricQueryTypes.query, + metricQueryType = grafana.target.cloudwatch.queryTypes.Query, dimensions = { TargetGroup: vars.target_group From c06dc6bfccbdc4847221b1f7ac60870cede2717c Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 2 Feb 2024 16:03:40 -0500 Subject: [PATCH 5/5] fix: dashed --- terraform/monitoring/panels/lb/error_4xx.libsonnet | 4 ++-- terraform/monitoring/panels/lb/error_5xx.libsonnet | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/terraform/monitoring/panels/lb/error_4xx.libsonnet b/terraform/monitoring/panels/lb/error_4xx.libsonnet index 15ae59f..6cc41e8 100644 --- a/terraform/monitoring/panels/lb/error_4xx.libsonnet +++ b/terraform/monitoring/panels/lb/error_4xx.libsonnet @@ -11,7 +11,7 @@ local _configuration = defaults.configuration.timeseries axisSoftMin = 0, axisSoftMax = threshold * 1.2, ) - .withThresholdStyle(grafana.fieldConfig.thresholdStyle.dashed) + .withThresholdStyle(grafana.fieldConfig.thresholdStyle.Dashed) .addThreshold({ color : defaults.values.colors.critical, value : threshold, @@ -29,7 +29,7 @@ local _configuration = defaults.configuration.timeseries axisSoftMin = 0, axisSoftMax = threshold * 1.2, ) - .withThresholdStyle(grafana.fieldConfig.thresholdStyle.dashed) + .withThresholdStyle(grafana.fieldConfig.thresholdStyle.Dashed) .addThreshold({ color : defaults.values.colors.critical, value : threshold, diff --git a/terraform/monitoring/panels/lb/error_5xx.libsonnet b/terraform/monitoring/panels/lb/error_5xx.libsonnet index 2a8412d..2cdef66 100644 --- a/terraform/monitoring/panels/lb/error_5xx.libsonnet +++ b/terraform/monitoring/panels/lb/error_5xx.libsonnet @@ -11,7 +11,7 @@ local _configuration = defaults.configuration.timeseries axisSoftMin = 0, axisSoftMax = threshold * 1.2, ) - .withThresholdStyle(grafana.fieldConfig.thresholdStyle.dashed) + .withThresholdStyle(grafana.fieldConfig.thresholdStyle.Dashed) .addThreshold({ color : defaults.values.colors.critical, value : threshold,