From 58ce2f75bba9683868a3ff5d9c9f3ff609c0e8c7 Mon Sep 17 00:00:00 2001 From: Xavier Basty Date: Wed, 7 Jun 2023 16:36:46 +0200 Subject: [PATCH] fix: lb metrics --- terraform/monitoring/dashboard.jsonnet | 1 + .../panels/lb/active_connections.libsonnet | 24 +++++++++++++++++++ .../panels/lb/healthy_hosts.libsonnet | 7 +++--- terraform/monitoring/panels/panels.libsonnet | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 terraform/monitoring/panels/lb/active_connections.libsonnet diff --git a/terraform/monitoring/dashboard.jsonnet b/terraform/monitoring/dashboard.jsonnet index c42494c..d3c3c13 100644 --- a/terraform/monitoring/dashboard.jsonnet +++ b/terraform/monitoring/dashboard.jsonnet @@ -63,6 +63,7 @@ dashboard.new( panels.history.registrations(ds, vars) { gridPos: pos._1 }, row.new('Load Balancer'), + panels.lb.active_connections(ds, vars) { gridPos: pos._2 }, panels.lb.healthy_hosts(ds, vars) { gridPos: pos._2 }, row.new('Database'), diff --git a/terraform/monitoring/panels/lb/active_connections.libsonnet b/terraform/monitoring/panels/lb/active_connections.libsonnet new file mode 100644 index 0000000..cae7e22 --- /dev/null +++ b/terraform/monitoring/panels/lb/active_connections.libsonnet @@ -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 = 'Active Connections', + datasource = ds.cloudwatch, + ) + .configure(defaults.configuration.timeseries) + + .addTarget(targets.cloudwatch( + datasource = ds.cloudwatch, + namespace = 'AWS/ApplicationELB', + metricName = 'ActiveConnectionCount', + dimensions = { + LoadBalancer: vars.load_balancer + }, + statistic = 'Average', + )) +} diff --git a/terraform/monitoring/panels/lb/healthy_hosts.libsonnet b/terraform/monitoring/panels/lb/healthy_hosts.libsonnet index a79c267..67c9952 100644 --- a/terraform/monitoring/panels/lb/healthy_hosts.libsonnet +++ b/terraform/monitoring/panels/lb/healthy_hosts.libsonnet @@ -19,7 +19,6 @@ local _configuration = defaults.configuration.timeseries .configure(_configuration) .addTarget(targets.cloudwatch( - alias = "eu-central-1", datasource = ds.cloudwatch, metricQueryType = grafana.target.cloudwatch.metricQueryTypes.query, @@ -27,11 +26,11 @@ local _configuration = defaults.configuration.timeseries TargetGroup: vars.target_group }, metricName = 'HealthyHostCount', - namespace = 'AWS/NetworkELB', + namespace = 'AWS/ApplicationELB', sql = { from: { property: { - name: "AWS/NetworkELB", + name: "AWS/ApplicationELB", type: "string" }, type: "property" @@ -63,7 +62,7 @@ local _configuration = defaults.configuration.timeseries type: "and" } }, - sqlExpression = "SELECT MAX(HealthyHostCount) FROM \"AWS/NetworkELB\" WHERE LoadBalancer = '%s'" % [vars.load_balancer], + sqlExpression = "SELECT MAX(HealthyHostCount) FROM \"AWS/ApplicationELB\" WHERE LoadBalancer = '%s'" % [vars.load_balancer], statistic = 'Maximum', )) } diff --git a/terraform/monitoring/panels/panels.libsonnet b/terraform/monitoring/panels/panels.libsonnet index 83084ab..3a5db0a 100644 --- a/terraform/monitoring/panels/panels.libsonnet +++ b/terraform/monitoring/panels/panels.libsonnet @@ -22,6 +22,7 @@ }, lb: { + active_connections: (import 'lb/active_connections.libsonnet' ).new, healthy_hosts: (import 'lb/healthy_hosts.libsonnet' ).new, } }