Retrieving Ec2 dimensions for cloudwatch alarms

Hello, does anyone has a solution to retrieve some dimensions from an EC2 in order to select the right CoudWatch metric for an alarm? I need the disk_used_percent and i’m having some trouble getting the device (ex: xvda1 ) and fstype (ex: xfs) dynamically.

Are you collecting them at the moment?
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html

Yes im collecting them but in order to specify the right disk_used_percent for the alarm i need to provide the right dimensions for it! The agent collects about 10 different disk_used_percent

I’ve just ignored what I dont want

I need to do this through a CF template or lambda and want it to be dynamic, some EC2 may have differente OS

“metrics_collected”: {
“disk”: {
“measurement”: [
“used_percent”
],
“metrics_collection_interval”: 60,
“resources”: [
“*”
],
“ignore_file_system_types”: [
“tmpfs”,
“devtmpfs”,
“sysfs”,
“squashfs”
]
},
“mem”: {
“measurement”: [
“used_percent”
],
“metrics_collection_interval”: 60
}
}

Im not sure off the top of my head how to get ONLY what you want

Ah. just saw your comment just before my paste.
If you get anywhere with the dynamic OS aspect please share.

Well that would work if i knew what to expect , that’s why i was thinking of getting the info directly from the EC2

Sure! Thanks for the answer as well

So because the metrics are “per-instance” the new instances aren’t being included in the alarm?

The OS shouldnt make too much difference on the disk_used_percent specifically

I think the file system type and even the device might change, maybe its always the same between each OS

Ah, so (i believe) cloudwatch doesnt support querying across metrics by instance.