AWS

CloudWatch Agent Supervisordのプロセス監視

AWS

sudo vi /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/supervisord

{
    "metrics": {
        "metrics_collected": {
            "procstat": [
                {
                    "pid_file": "/var/run/supervisord.pid",
                    "measurement": [
                        "pid_count"
                    ],
                    "metrics_collection_interval": 60
                }
            ]
        }
    }
}

 

実際はこんなの

 

{
    "agent": {
        "metrics_collection_interval": 60,
        "run_as_user": "root"
    },
    "metrics": {
        "aggregation_dimensions": [
            [
                "InstanceId"
            ]
        ],
        "append_dimensions": {
            "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
            "ImageId": "${aws:ImageId}",
            "InstanceId": "${aws:InstanceId}",
            "InstanceType": "${aws:InstanceType}"
        },
        "metrics_collected": {
            "collectd": {
                "metrics_aggregation_interval": 60
            },
            "procstat": [
                {
                    "pid_file": "/var/run/supervisord.pid",
                    "measurement": [
                        "pid_count"
                    ],
                    "metrics_collection_interval": 60
                }
            ],
            "ethtool": {
              "interface_include": [
                "eth0"
              ],
              "metrics_include": [
                "rx_packets",
                "tx_packets",
                "bw_in_allowance_exceeded",
                "bw_out_allowance_exceeded",
                "conntrack_allowance_exceeded",
                "linklocal_allowance_exceeded",
                "pps_allowance_exceeded"
               ]
            },
            "net": {
                "measurement": [
                    "bytes_sent",
                    "bytes_recv",
                    "drop_in",
                    "drop_out",
                    "err_in",
                    "err_out",
                    "packets_sent",
                    "packets_recv"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "cpu": {
                "measurement": [
                    "cpu_usage_idle",
                    "cpu_usage_iowait",
                    "cpu_usage_user",
                    "cpu_usage_system"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ],
                "totalcpu": false
            },
            "disk": {
                "measurement": [
                    "used_percent",
                    "inodes_free",
                    "inodes_used",
                    "inodes_total"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "diskio": {
                "measurement": [
                    "io_time",
                    "write_bytes",
                    "read_bytes",
                    "writes",
                    "reads"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "mem": {
                "measurement": [
                    "mem_used_percent"
                ],
                "metrics_collection_interval": 60
            },
            "swap": {
                "measurement": [
                    "swap_used_percent",
                    "swap_used"
                ],
                "metrics_collection_interval": 60
            },
            "netstat": {
                "measurement": [
                    "tcp_established",
                    "tcp_time_wait"
                ],
                "metrics_collection_interval": 60
            },
            "statsd": {
                "metrics_aggregation_interval": 60,
                "metrics_collection_interval": 10,
                "service_address": ":8125"
            }
        }
    },
    "logs": {
        "logs_collected": {
            "files": {
                "collect_list": [
                    {
                        "file_path": "/var/www/product/storage/logs/laravel*log",
                        "log_group_name": "/ec2/sample/production/job/laravel",
                        "log_stream_name": "ec2-{instance_id}-laravel"
                    },
                    {
                        "file_path": "/var/www/product/storage/logs/request*log",
                        "log_group_name": "/ec2/sample/production/job/laravel/request",
                        "log_stream_name": "ec2-{instance_id}-laravel-request"
                    },
                    {
                        "file_path": "/var/log/nginx/*.log*",
                        "log_group_name": "/ec2/sample/production/job/api/nginx",
                        "log_stream_name": "ec2-{instance_id}-nginx"
                    },
                    {
                        "file_path": "/var/log/nginx/error.log",
                        "log_group_name": "/ec2/sample/production/job/api/nginx/error",
                        "log_stream_name": "ec2-{instance_id}-nginx-error"
                    },
                    {
                         "file_path": "/var/log/php7.2-fpm.log",
                         "log_group_name": "/ec2/sample/production/job/api/php-fpm",
                         "log_stream_name": "ec2-{instance_id}-php-fpm"
                    },
                    {
                        "file_path": "/var/log/php7.2-fpm-slow.log",
                        "log_group_name": "/ec2/sample/production/job/api/php-fpm/slow",
                        "log_stream_name": "ec2-{instance_id}-php-fpm-slow"
                    }
                ]
            }
        }
    }
}

関連

CloudWatch Agent Laravelログ出力 AutoScalingGroup環境

 

 

Amazonおすすめ

iPad 9世代 2021年最新作

iPad 9世代出たから買い替え。安いぞ!🐱 初めてならiPad。Kindleを外で見るならiPad mini。ほとんどの人には通常のiPadをおすすめします><

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)