简体   繁体   English

使用 boto3 在 EMR 上发出 AWS CloudWatch 警报

[英]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.我需要使用 boto3 创建脚本,只要集群中的实例不正常,它就会从 AWS CloudWatch 发送电子邮件通知。

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.我正在按照put_metric_alarm()文档创建 boto3 脚本,我发现为了达到我的要求,我可以使用MRUnhealthyNodes度量类型。 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?我是 AWS 世界的新手,有人可以帮助我吗? Thank you in advance!先感谢您!

The valid dimensions for EMR metrics are listed in Dimensions for Amazon EMR Metrics : EMR 指标的有效维度列在Amazon EMR 指标的维度中

JobFlowId - The same as cluster ID, which is the unique identifier of a cluster in the form j-XXXXXXXXXXXXX. JobFlowId - 与集群 ID 相同,是集群的唯一标识符,格式为 j-XXXXXXXXXXXXX。 Find this value by clicking on the cluster in the Amazon EMR console.通过单击 Amazon EMR 控制台中的集群来查找此值。

JobId - The identifier of a job within a cluster. JobId - 集群中作业的标识符。 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. JobId 采用 job_XXXXXXXXXXXX_XXXX 形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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