With this we can configure dimensions for our custom metric.
{
"metrics":{
"append_dimensions":{
"AutoScalingGroupName":"${!aws:AutoScalingGroupName}",
"ImageId":"${!aws:ImageId}",
"InstanceId":"${!aws:InstanceId}",
"InstanceType":"${!aws:InstanceType}"
},
"metrics_collected":{
"mem":{
"measurement":[
"mem_used_percent"
]
},
"swap":{
"measurement":[
"swap_used_percent"
]
}
}
}
}
Now I try to create an alarm for the dimension autoscaling group:
MemoryAlarmHigh:
Type: AWS::CloudWatch::Alarm
Properties:
EvaluationPeriods: '1'
Statistic: Average
Threshold: '70'
AlarmDescription: Go in Alarm is memory is higher than 70% for 60 seconds
Period: '60'
AlarmActions:
- Ref: ScaleUpPolicy
Namespace: CWAgent
Dimensions:
- Name: AutoScalingGroupName
Value: !Ref ASG
ComparisonOperator: GreaterThanThreshold
MetricName: xxx
This does not work. I get insufficient data. Now when I use
{
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}"
},
"metrics_collected": {
"mem": {
"measurement": [
"mem_used_percent"
]
}
}
}
}
And the alarm works now. But I want to use multiple dimensions but use them separately (like in the EC2 namespace) so I can use my alarm.
How can I do this?
Try setting aggregation_dimensions
.
Like this:
{
"metrics":{
"append_dimensions":{
"AutoScalingGroupName":"${!aws:AutoScalingGroupName}",
"ImageId":"${!aws:ImageId}",
"InstanceId":"${!aws:InstanceId}",
"InstanceType":"${!aws:InstanceType}"
},
"aggregation_dimensions" : [["AutoScalingGroupName"]],
"metrics_collected":{
"mem":{
"measurement":[
"mem_used_percent"
]
},
"swap":{
"measurement":[
"swap_used_percent"
]
}
}
}
}