Skip to content

customized_metric_specification metrics is missing #225

@tetienne

Description

@tetienne

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.

  • ✋ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions