Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
fix: grafana dashboard creation (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Basty committed Jul 4, 2023
1 parent ccc9b00 commit 423ab4e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 63 deletions.
4 changes: 2 additions & 2 deletions terraform/monitoring/dashboard.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ dashboard.new(
panels.lb.healthy_hosts(ds, vars) { gridPos: pos._2 },

panels.lb.requests(ds, vars) { gridPos: pos._3 },
panels.lb.error_4xx(ds, vars) { gridPos: pos._3 },
panels.lb.error_5xx(ds, vars) { gridPos: pos._3 },
// panels.lb.error_4xx(ds, vars) { gridPos: pos._3 },
// panels.lb.error_5xx(ds, vars) { gridPos: pos._3 },

row.new('Database'),
panels.db.cpu(ds, vars) { gridPos: pos._3 },
Expand Down
1 change: 1 addition & 0 deletions terraform/monitoring/panels/app/memory.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local targets = grafana.targets;
datasource = ds.cloudwatch,
)
.configure(defaults.overrides.memory(defaults.configuration.timeseries_resource))

.setAlert(defaults.alerts.memory(
namespace = vars.namespace,
title = 'ECS',
Expand Down
43 changes: 12 additions & 31 deletions terraform/monitoring/panels/lb/error_4xx.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,29 @@ local _configuration = defaults.configuration.timeseries
value : threshold,
});

local _alert(namespace, env, notifications) = grafana.alert.new(
namespace = namespace,
name = "%(env)s - 4XX alert" % { env: grafana.utils.strings.capitalize(env) },
message = '%(env)s - Too many 4XX' % { env: grafana.utils.strings.capitalize(env) },
notifications = notifications,
noDataState = 'no_data',
conditions = [
grafana.alertCondition.new(
evaluatorParams = [ threshold ],
evaluatorType = 'gt',
operatorType = 'or',
queryRefId = 'ELB',
queryTimeStart = '5m',
queryTimeEnd = 'now',
reducerType = grafana.alert_reducers.Avg
),
grafana.alertCondition.new(
evaluatorParams = [ threshold ],
evaluatorType = 'gt',
operatorType = 'or',
queryRefId = 'Target',
queryTimeStart = '5m',
queryTimeEnd = 'now',
reducerType = grafana.alert_reducers.Avg
),
],
);

{
new(ds, vars)::
panels.timeseries(
title = '4XX',
datasource = ds.cloudwatch,
)
.configure(_configuration)
.configure(
defaults.configuration.timeseries
.withSoftLimit(
axisSoftMin = 0,
axisSoftMax = threshold * 1.2,
)
.withThresholdStyle(grafana.fieldConfig.thresholdStyle.dashed)
.addThreshold({
color : defaults.values.colors.critical,
value : threshold,
})
)
.addPanelThreshold(
op = 'gt',
value = threshold,
)

.setAlert(_alert(vars.namespace, vars.environment, vars.notifications))

.addTarget(targets.cloudwatch(
alias = 'ELB',
datasource = ds.cloudwatch,
Expand Down
30 changes: 0 additions & 30 deletions terraform/monitoring/panels/lb/error_5xx.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,6 @@ local _configuration = defaults.configuration.timeseries
value : threshold,
});

local _alert(namespace, env, notifications) = grafana.alert.new(
namespace = namespace,
name = "%(env)s - 5XX alert" % { env: grafana.utils.strings.capitalize(env) },
message = '%(env)s - Too many 5XX' % { env: grafana.utils.strings.capitalize(env) },
notifications = notifications,
noDataState = 'no_data',
conditions = [
grafana.alertCondition.new(
evaluatorParams = [ threshold ],
evaluatorType = 'gt',
operatorType = 'or',
queryRefId = 'ELB',
queryTimeStart = '5m',
queryTimeEnd = 'now',
reducerType = grafana.alert_reducers.Avg
),
grafana.alertCondition.new(
evaluatorParams = [ threshold ],
evaluatorType = 'gt',
operatorType = 'or',
queryRefId = 'Target',
queryTimeStart = '5m',
queryTimeEnd = 'now',
reducerType = grafana.alert_reducers.Avg
),
],
);

{
new(ds, vars)::
panels.timeseries(
Expand All @@ -57,8 +29,6 @@ local _alert(namespace, env, notifications) = grafana.alert.new(
value = threshold,
)

.setAlert(_alert(vars.namespace, vars.environment, vars.notifications))

.addTarget(targets.cloudwatch(
alias = 'ELB',
datasource = ds.cloudwatch,
Expand Down

0 comments on commit 423ab4e

Please sign in to comment.