# Metric expression in TargetTrackingScaling aws\_autoscaling\_policy

**URL:** <https://discuss.hashicorp.com/t/metric-expression-in-targettrackingscaling-aws-autoscaling-policy/52121>\
**Category:** AWS\
**Created:** [March 30, 2023, 3:10pm UTC](https://discuss.hashicorp.com/t/metric-expression-in-targettrackingscaling-aws-autoscaling-policy/52121 "2023-03-30T15:10:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![st.shishkin](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@st.shishkin](https://discuss.hashicorp.com/u/st.shishkin)\
**Post date:** [March 30, 2023, 3:10pm UTC](https://discuss.hashicorp.com/t/metric-expression-in-targettrackingscaling-aws-autoscaling-policy/52121/1 "2023-03-30T15:10:27Z")

</div>

I try to use a metric expression for my autoscaling group almost as in the example at [Terraform Registry](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_policy#create-target-tarcking-scaling-policy-using-metric-math).

but I’ve got the following policy in the AWS console. which is looking not so good.

 ![screenshot1](https://global.discourse-cdn.com/hashicorp/original/3X/2/8/2818072cb9141a66d2d8f5f79d25e918c4321f8a.png)  
and I can’t do the same policy by the UI.

and also autoscaling doesn’t work. even when the metrics have the following values

 ![screenshot2](https://global.discourse-cdn.com/hashicorp/original/3X/8/f/8f74cf7fd02a04d9945526f3a2523fb0e99d8d7b.png)

is this option still supported? can you please help me to figure this out?

forgot to provide source code:

```auto
resource "aws_autoscaling_policy" "calls" {
  autoscaling_group_name = aws_autoscaling_group.asterisk.name
  name = "calls"
  policy_type = "TargetTrackingScaling"

  target_tracking_configuration {
    target_value = 10
    customized_metric_specification {
      metrics {
        label = "Total calls number"
        id = "totalcount"
        metric_stat {
          metric {
            namespace = "my_namespace"
            metric_name = "totalcount"
            dimensions {
              name = "Environment"
              value = local.tags["Environment"]
            }
          }
          stat = "Average"
        }
        return_data = false
      }
      metrics {
        label = "Get the group size"
        id = "number"
        metric_stat {
          metric {
            namespace = "AWS/AutoScaling"
            metric_name = "GroupInServiceInstances"
            dimensions {
              name = "AutoScalingGroupName"
              value = aws_autoscaling_group.asterisk.name
            }
          }
          stat = "Average"
        }
        return_data = false
      }
      metrics {
        label = "Calculate calls per instance"
        id = "e1"
        expression = "totalcount / number"
        return_data = true
      }
    }
  }
}

```
