Skip to content

Commit

Permalink
Correct monitoring dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjjung committed Nov 21, 2024
1 parent 97ee51f commit 6a0a8ba
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tb_pulumi/cloudwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(
f'{self.name}-5xx',
name=f'{self.project.name_prefix}-5xx',
comparison_operator='GreaterThanOrEqualToThreshold',
dimensions={'LoadBalancer': f'app/{outputs['res_name']}/{outputs['res_suffix']}'},
dimensions={'LoadBalancer': outputs['res_suffix']},
metric_name='HTTPCode_ELB_5XX_Count',
namespace='AWS/ApplicationELB',
alarm_description=f'Elevated 5xx errors on ALB {outputs['res_name']}',
Expand Down Expand Up @@ -160,7 +160,7 @@ def __init__(
f'{self.name}-responsetime',
name=f'{self.project.name_prefix}-responsetime',
comparison_operator='GreaterThanOrEqualToThreshold',
dimensions={'LoadBalancer': f'app/{outputs['res_name']}/{outputs['res_suffix']}'},
dimensions={'LoadBalancer': outputs['res_suffix']},
metric_name='TargetResponseTime',
namespace='AWS/ApplicationELB',
alarm_description=f'Average response time is over {response_time_opts['threshold']} second(s) for {response_time_opts['period']} seconds', # noqa: E501
Expand Down Expand Up @@ -233,7 +233,9 @@ def __init__(
f'{self.name}-cpu',
name=f'{self.project.name_prefix}-cpu',
comparison_operator='GreaterThanOrEqualToThreshold',
dimensions={'ServiceName': res_name},
# There is no direct way to get the Cluster name from a Service, but we can get the ARN, which has the
# name as the final portion after the last slash.
dimensions={'ClusterName': resource.cluster_arn.split('/')[-1], 'ServiceName': res_name},
metric_name='CPUUtilization',
namespace='AWS/ECS',
alarm_description=f'CPU utilization on the {res_name} cluster exceeds '
Expand Down Expand Up @@ -263,7 +265,9 @@ def __init__(
f'{self.name}-memory',
name=f'{self.project.name_prefix}-memory',
comparison_operator='GreaterThanOrEqualToThreshold',
dimensions={'ServiceName': res_name},
# There is no direct way to get the Cluster name from a Service, but we can get the ARN, which has the
# name as the final portion after the last slash.
dimensions={'ClusterName': resource.cluster_arn.split('/')[-1], 'ServiceName': res_name},
metric_name='MemoryUtilization',
namespace='AWS/ECS',
alarm_description=f'Memory utilization on the {res_name} cluster exceeds '
Expand Down

0 comments on commit 6a0a8ba

Please sign in to comment.