Bootstrap

AWS CloudWatch监控之钉钉告警

d8f6686ab0681b4e7b724f19c89ec205.gif

新钛云服已累计为您分享709篇技术干货

1bdd99357b0a80fb62c3c28cc286af12.gif

ef8df706e98373192e742fceb9c8b44d.png

、CloudWatch服务安装

Amazon Linux 2系统安装Agent

cb84d9fed8c6038e18081d31e012c175.png

Bash
#!/bin/bash
rpm  -ivh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm

sudo tee -a /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json   <<-'EOF'
{
        "logs": {
                "logs_collected": {
                        "files": {
                                "collect_list": [
                                        {
                                                "file_path": "/logArchive/hcaextension/info*.log",
                                                "log_group_name": "RGC-Prod-3in1oven",
                                                "log_stream_name": "info.logs"
                                        },
                                        {
                                                "file_path": "/logArchive/hcaextension/http*.log",
                                                "log_group_name": "RGC-Prod-3in1oven",
                                                "log_stream_name": "http.logs"
                                        }
                                ]
                        }
                }
        },
        "metrics": {
                "aggregation_dimensions": [
                        [
                                "InstanceId"
                        ]
                ],
                "append_dimensions": {
                        "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
                        "ImageId": "${aws:ImageId}",
                        "InstanceId": "${aws:InstanceId}",
                        "InstanceType": "${aws:InstanceType}"
                },
                "metrics_collected": {
                        "cpu": {
                                "measurement": [
                                        "cpu_usage_idle",
                                        "cpu_usage_iowait",
                                        "cpu_usage_user",
                                        "cpu_usage_system"
                                ],
                                "metrics_collection_interval": 180,
                                "resources": [
                                        "*"
                                ],
                                "totalcpu": false
                        },
                        "disk": {
                                "measurement": [
                                        "used_percent"
                                ],
                                "metrics_collection_interval": 180,
                                "resources": [
                                        "/"
                                ]
                        },
                        "diskio": {
                                "measurement": [
                                        "io_time",
                                        "write_bytes",
                                        "read_bytes",
                                        "writes",
                                        "reads"
                                ],
                                "metrics_collection_interval": 180,
                                
;