I need to capture variable value for Linux EC2 instances.
'Name': 'device',
'Value': "xvdg"
The value Disk Name(device name) changes for EC2 Linux instances e.g sdh
,xvdg
, etc..
I am using boto3 SDK
Any help is much appreciated.
Current Code (Hard coded the Device Name):
cloudwatch.put_metric_alarm(
AlarmName=prefix + ' - Elastic Search Disc % Availabilty is less than the configured threshold value - Please increase size of EBS Volume',
ComparisonOperator='LowerThanThreshold',
EvaluationPeriods=3,
MetricName='disk_used_percent',
Namespace='CWAgent',
Period=300,
Statistic='Average',
Threshold=75,
AlarmActions=[snstopicarn],
AlarmDescription='Standard Disc Alert - Elastic Search Disc % Availabilty is less than the configured threshold value - Please increase size of EBS Volume',
Dimensions=[
{
'Name': 'InstanceId',
'Value': instance["InstanceId"]
},
{
'Name': 'path',
'Value': "/mnt/elasticsearch"
},
{
'Name': 'device',
'Value': "xvdi"
},
{
'Name': 'fstype',
'Value': "ext4"
},
]
)