cdk-monitoring-constructs icon indicating copy to clipboard operation
cdk-monitoring-constructs copied to clipboard

[Refactor] Mix-up of NLB and ECS APIs

Open r0b0ji opened this issue 2 years ago • 2 comments

Currently, I see the ECS monitoring has been combined with NLB, ALB. For ex:

  1. monitorFargateService: monitors Fargate service, loadbalancer, targetGroup
  2. monitorSimpleFargateService: monitors Fargate service
  3. monitorFargateNetworkLoadBalancer: looks similar to monitorFargateService but here the loadbalancer and target group are passed separately and not from FargateService
  4. monitorApplicationLoadBalancer: similar to monitorFargateNetworkLoadBalancer but instead of NLB, it is for ALB
  5. monitorQueueProcessingFargateService:
  6. monitorQueueProcessingEc2Service

A better refactor and re-org in my opinion should be to split into specific parts and each part responsible for monitoring its own resource. This is my initial refactor proposal, but feel free to discuss and refactor as required.

Let's just have monitorSimpleFargateService and monitorSimpleEc2Service (we can even remove simple from name), where first monitors just FargateService and second monitors just Ec2Service. Then have monitorNetworkLoadBalancer, which monitors NetworkLoadBalancer and NetworkTarget Group, monitorApplicationLoadBalancer which monitors ApplicationLoadBalancer and ApplicationTargetGroup.

Now,

  1. remove /lib/monitoring/aws-ecs-patterns module or maybe keep it and then monitorNetworkLoadBalancedFargateService internally calls monitorFargateService, monitorNetworkLoadBalancer, monitorApplicationLoadBalancedFargateService calls monitorFargateService, monitorApplicationLoadBalancer, monitorQueueProcessingFargateService calls monitorFargateService and monitorSQS. Same for Ec2Service
  2. add a module /lib/monitoring/aws-ecs, this module contains monitorFargateService, monitorEc2Service

This is my mental model. I am happy to discuss more.

r0b0ji avatar Apr 13 '22 15:04 r0b0ji

Wanted to pipe in my two cents and support this. While it's nice to have the high level combined patterns, my expectation is it's ultimately instrumenting the primitives and underlying services.

RichiCoder1 avatar Jul 05 '22 18:07 RichiCoder1

I agree that this is the right way to do it. But we have to handle this in a backwards-compatible way. Internally, I believe we already have a separation for service / load balancer / target group, but the API combines them.

voho avatar Aug 23 '22 15:08 voho