Skip to content

Commit

Permalink
feat(monitoring): changing to use Prometheus data for the CPU usage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbrother authored Feb 23, 2024
1 parent 02cdfa8 commit cd66e9c
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions terraform/monitoring/panels/ecs/cpu.libsonnet
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
local grafana = import '../../grafonnet-lib/grafana.libsonnet';
local defaults = import '../../grafonnet-lib/defaults.libsonnet';

local panels = grafana.panels;
local targets = grafana.targets;
local overrides = defaults.overrides;
local panels = grafana.panels;
local targets = grafana.targets;
local alert = grafana.alert;
local alertCondition = grafana.alertCondition;
local overrides = defaults.overrides;

{
new(ds, vars)::
panels.timeseries(
title = 'CPU Utilization',
datasource = ds.cloudwatch,
datasource = ds.prometheus,
)
.configure(overrides.cpu(defaults.configuration.timeseries_resource))
.setAlert(defaults.alerts.cpu(
.setAlert(alert.new(
namespace = 'RPC Proxy',
env = vars.environment,
title = 'ECS',
name = "RPC %s - High CPU usage" % vars.environment,
message = "RPC %s - High CPU usage" % vars.environment,
period = '5m',
frequency = '1m',
noDataState = 'alerting',
notifications = vars.notifications,
))

.addTarget(targets.cloudwatch(
alias = 'CPU (Max)',
datasource = ds.cloudwatch,
dimensions = {
ServiceName: vars.ecs_service_name
alertRuleTags = {
'og_priority': 'P3',
},
metricName = 'CPUUtilization',
namespace = 'AWS/ECS',
statistic = 'Maximum',
refId = 'CPU_Max',
conditions = [
alertCondition.new(
evaluatorParams = [ 70 ],
evaluatorType = 'gt',
operatorType = 'or',
queryRefId = 'CPU_Avg',
queryTimeStart = '5m',
reducerType = 'avg',
),
]
))
.addTarget(targets.cloudwatch(
alias = 'CPU (Avg)',
datasource = ds.cloudwatch,
dimensions = {
ServiceName: vars.ecs_service_name
},
metricName = 'CPUUtilization',
namespace = 'AWS/ECS',
statistic = 'Average',
.addTarget(targets.prometheus(
datasource = ds.prometheus,
expr = 'sum(rate(cpu_usage_sum[$__rate_interval])) / sum(rate(cpu_usage_count[$__rate_interval]))',
refId = 'CPU_Avg',
))
}

0 comments on commit cd66e9c

Please sign in to comment.