terraform-aws-ecs icon indicating copy to clipboard operation
terraform-aws-ecs copied to clipboard

customized_metric_specification metrics is missing

Open tetienne opened this issue 1 year ago β€’ 2 comments

Description

While trying to add a custom metric for one of my project, I was not able to find how to specify... well the metrics.

It looks like this field is not handle. Here the definition of customized_metric_specification, and here where this module build it. If I’m not wrong the metrics attribute is missing.

  • [x] βœ‹ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]:

  • Terraform version: 1.5

  • Provider version(s): v5.63.1

Reproduction Code [Required]

module "web_service" {
  source                     = "terraform-aws-modules/ecs/aws//modules/service"
  version                    = "5.11.4"
  name                       = "api"
  ...
  autoscaling_min_capacity   = var.autoscaling_min_capacity
  autoscaling_max_capacity   = var.autoscaling_max_capacity
  autoscaling_policies = {
    cpu = {
      policy_type = "TargetTrackingScaling"
      target_tracking_scaling_policy_configuration = {
        target_value = 60
        customized_metric_specification = {
          metric_name = "AdjustedCpuUtilization"
          namespace   = "ECS/Custom"
          statistic   = "Average"
          unit        = "Percent"
          dimensions = [
            {
              name  = "ClusterName"
              value = local.cluster_name
            },
            {
              name  = "ServiceName"
              value = local.service_name
            }
          ]

          metrics = [
            {
              id          = "m1"
              label       = "CpuUtilized"
              metric_name = "CpuUtilized"
              namespace   = "ECS/ContainerInsights"
              stat        = "Average"
              dimensions = [
                {
                  name  = "ClusterName"
                  value = local.cluster_name
                },
                {
                  name  = "ServiceName"
                  value = local.service_name
                }
              ]
              return_data = false
            },
            {
              id          = "m2"
              label       = "CpuReserved"
              metric_name = "CpuReserved"
              namespace   = "ECS/ContainerInsights"
              stat        = "Average"
              dimensions = [
                {
                  name  = "ClusterName"
                  value = local.cluster_name
                },
                {
                  name  = "ServiceName"
                  value = local.service_name
                }
              ]
              return_data = false
            },
            {
              id          = "m3"
              label       = "Running Task Count"
              metric_name = "RunningTaskCount"
              namespace   = "ECS/ContainerInsights"
              stat        = "Average"
              dimensions = [
                {
                  name  = "ClusterName"
                  value = local.cluster_name
                },
                {
                  name  = "ServiceName"
                  value = local.service_name
                }
              ]
              return_data = false
            },
            {
              id          = "m4"
              label       = "Mitigated Host Count"
              metric_name = "MitigatedHostCount"
              namespace   = "AWS/ApplicationELB"
              stat        = "Average"
              dimensions = [
                {
                  name  = "LoadBalancer"
                  value = data.aws_alb.external[0].arn_suffix
                },
                {
                  name  = "TargetGroup"
                  value = aws_lb_target_group.web[0].arn_suffix
                }
              ]
              return_data = false
            },
            # Expression 1: CpuUtilization = (100 * CpuUtilized) / CpuReserved
            {
              id          = "e1"
              expression  = "(100 * m1) / m2"
              label       = "CpuUtilization"
              return_data = false
            },
            # Expression 2: AdjustedCpuUtilization = (CpuUtilization * NumberOfTasks) / (NumberOfTasks - MitigatedHostCount)
            {
              id          = "e2"
              expression  = "(e1 * m3) / (m3 - m4)"
              label       = "AdjustedCpuUtilization"
              return_data = true
            }
          ]
        }
        scale_in_cooldown  = 300
        scale_out_cooldown = 60
      }
    }
  }

Expected behavior

Be able to create an autoscalling policy based on a custom metrics.

Actual behavior

metrics is not handle.

tetienne avatar Sep 05 '24 14:09 tetienne

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Oct 17 '24 00:10 github-actions[bot]

Still relevant

tetienne-zenchef avatar Oct 17 '24 07:10 tetienne-zenchef

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Nov 17 '24 00:11 github-actions[bot]

This issue was automatically closed because of stale in 10 days

github-actions[bot] avatar Nov 28 '24 00:11 github-actions[bot]

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Dec 28 '24 02:12 github-actions[bot]

This issue has been resolved in version 6.0.0 :tada:

antonbabenko avatar Jul 07 '25 12:07 antonbabenko