简体   繁体   中英

AWS CloudWatch alarm on EMR using boto3

I need to create script using boto3 which should make sending email notifications from AWS CloudWatch whenever instance in cluster is unhealthy.

I'm following put_metric_alarm() documentation to create boto3 script, and I found that to achieve my requirement I can use MRUnhealthyNodes metric type. I've written a small script to create alarm which should work:

client.put_metric_alarm (
AlarmName='name',
AlarmDescription='alarm description',
AlarmActions=[
    'sns:arn',
],
MetricName='MRUnhealthyNodes',
Namespace='AWS/ElasticMapReduce',
Statistic='Minimum',
Dimensions=[
    {
        'Name': 'string',
        'Value': 'string'
    },
],
Period=300,  
EvaluationPeriods=287,
Threshold=1,
ComparisonOperator='GreaterThanOrEqualToThreshold'

)

Here, I'm little confused what should be the value for:

Dimensions=[
    {
        'Name': 'string',
        'Value': 'string'
    },
]

I am new in the AWS world, so can someone help me with this? Thank you in advance!

The valid dimensions for EMR metrics are listed in Dimensions for Amazon EMR Metrics :

JobFlowId - The same as cluster ID, which is the unique identifier of a cluster in the form j-XXXXXXXXXXXXX. Find this value by clicking on the cluster in the Amazon EMR console.

JobId - The identifier of a job within a cluster. You can use this to filter the metrics returned from a cluster down to those that apply to a single job within the cluster. JobId takes the form job_XXXXXXXXXXXX_XXXX.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM