惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
Cloudbric
Cloudbric
G
Google Developers Blog
博客园_首页
博客园 - 司徒正美
N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
博客园 - 叶小钗
C
Check Point Blog
L
LangChain Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Scott Helme
Scott Helme
Last Week in AI
Last Week in AI
博客园 - 聂微东
T
Threat Research - Cisco Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Hacker News
The Hacker News
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
AWS News Blog
AWS News Blog
C
CERT Recently Published Vulnerability Notes
Google DeepMind News
Google DeepMind News
N
News | PayPal Newsroom
Help Net Security
Help Net Security
B
Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Tenable Blog
I
InfoQ
S
Securelist
V
Visual Studio Blog
U
Unit 42
博客园 - 【当耐特】
S
Security @ Cisco Blogs

博客园 - Don

在Chrome中调试Android微信浏览器中的网页,不出现供选择页面的怎么办?(chrome://inspect/#devices) 使用Crontab集合sh脚本自动删除过期的Confluence Docker容器中的备份文件 Docker PHP中安装gd扩展并生成图形验证码 解决命令行提示“cannot create temp file for here-document: No space left on device”但磁盘使用率并未满的问题 SSH登录后提示LC_ALL: cannot change locale (en_US.UTF8) 的解决办法 解决git操作一直要求输入用户名和密码的问题 CentOS如何增加虚拟内存 RabbitMQ集群脑裂故障处理 zookeeper日志定时清理 Alibaba Centos ECS 安全更新记录 记录AWS Linux2 的yum安全更新步骤 记录Docker系统盘空间占用过大的解决方法 AWS EC2 EBS数据盘挂载与相关日常维护操作 AWS Amazon Linux2 安装Docker和Docker Compose [转]提升 Docker Desktop For macOS 磁盘使用率 AndroidGetAPKInfo --- 检查包名(packageName)、版本(versionName\versionCode)、应用签名(Signature)等信息 - Don OpenSSL命令—pkcs12 Linux下User与Group的常用操作命令解析 Docker搭建openvpn - Don
AWS EC2配置CloudWatch
Don · 2022-07-12 · via 博客园 - Don

 1.创建IAM角色并关联到EC2

2.安装cloudwatch代理

3.生成代理配置文件

4.启动代理

Linux
sudo mkdir -p /usr/share/collectd
cd /usr/share/collectd
sudo touch types.db
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status

tail -f /opt/aws/amazon-cloudwatch-agent/logs/configuration-validation.log

Windows(powershell下执行)

& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:"C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json"

5.创建报警规则

常用命令:

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard   

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a stop   

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a start  

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status 

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json  

修改agent配置参数:

sudo vi /opt/aws/amazon-cloudwatch-agent/bin/config.json

重启agent使配置生效:

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json

当前配置config.json示例:

{

        "agent": {

                "metrics_collection_interval"60,

                "run_as_user""root"

        },

        "metrics": {

                "append_dimensions": {

                        "AutoScalingGroupName""${aws:AutoScalingGroupName}",

                        "ImageId""${aws:ImageId}",

                        "InstanceId""${aws:InstanceId}",

                        "InstanceType""${aws:InstanceType}"

                },

                "metrics_collected": {

                        "collectd": {

                                "metrics_aggregation_interval"60

                        },

                        "disk": {

                                "measurement": [

                                        "used_percent"

                                ],

                                "metrics_collection_interval"60,

                                "resources": [

                                        "/",

                                        "/mnt"

                                ]

                        },

                        "mem": {

                                "measurement": [

                                        "mem_used_percent"

                                ],

                                "metrics_collection_interval"60

                        },

                        "statsd": {

                                "metrics_aggregation_interval"60,

                                "metrics_collection_interval"10,

                                "service_address"":8125"

                        }

                }

        }

}

amazon-cloudwatch-agent-ctl参数说明:

usage: amazon-cloudwatch-agent-ctl -a

stop|start|status|fetch-config|append-config|remove-config [-m

ec2|onPremise|auto] [-c default|all|ssm:<parameter-store-name>|file:<file-path>] [-o default|all|ssm:<parameter-store-name>|file:<file-path>] [-s]

e.g.

1. apply a SSM parameter store config on EC2 instance and restart the agent afterwards:

    amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:AmazonCloudWatch-Config.json -s

2. append a local json config file on onPremise host and restart the agent afterwards:

    amazon-cloudwatch-agent-ctl -a append-config -m onPremise -c file:/tmp/config.json -s

3. query agent status:

    amazon-cloudwatch-agent-ctl -a status

-a: action

    stop:                                   stop the agent process.

    start:                                  start the agent process.

    status:                                 get the status of the agent process.

    fetch-config:                           apply config for agent, followed by -c or -o or both. Target config can be based on location (ssm parameter store name, file name), or 'default'.

    append-config:                          append json config with the existing json configs if any, followed by -c. Target config can be based on the location (ssm parameter store name, file name), or 'default'.

    remove-config:                          remove config for agent, followed by -c or -o or both. Target config can be based on the location (ssm parameter store name, file name), or 'all'.

-m: mode

    ec2:                                    indicate this is on ec2 host.

    onPremise:                              indicate this is on onPremise host.

    auto:                                   use ec2 metadata to determine the environment, may not be accurate if ec2 metadata is not available for some reason on EC2.

-c: amazon-cloudwatch-agent configuration

    default:                                default configuration for quick trial.

    ssm:<parameter-store-name>:             ssm parameter store name.

    file:<file-path>:                       file path on the host.

    all:                                    all existing configs. Only apply to remove-config action.

-o: cwagent-otel-collector configuration

    default:                                default configuration for quick trial.

    ssm:<parameter-store-name>:             ssm parameter store name.

    file:<file-path>:                       file path on the host.

    all:                                    all existing configs. Only apply to remove-config action.

-s: optionally restart after configuring the agent configuration

    this parameter is used for 'fetch-config''append-config''remove-config' action only.

参考来源:https://docs.amazonaws.cn/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html