方法1:mon-cmd
http://docs.aws.amazon.com/zh_cn/AmazonCloudWatch/latest/cli/SetupCLI.html(安装连接)
● Step 1: Install the CLI
● Step 2: Configure the CLI for Your Credentials
● Step 3: Set the Region
● Step 4: Test Your CLI Configuration
安装过程:
一、安装java(1.5以上)
安装包:jre-8u-linux-x64.rpm
export JAVA_HOME=/usr/java/jre1.8.0_131/
export PATH=$PATH:$JAVA_HOME/bin
二、安装cloudwatch
1、下载CloudWatch-2010-08-01.zip包
export AWS_CLOUDWATCH_HOME=/usr/local/src/aws/CloudWatch-1.0.20.0
export PATH=$PATH:$AWS_CLOUDWATCH_HOME/bin
2、修改credential-file-path.template 文件
cat CloudWatch-1.0.20.0/credential-file-path.template
AWSAccessKeyId=
AWSSecretKey=
3、set the region
export AWS_CLOUDWATCH_URL=http://monitoring.us-west-1.amazonaws.com/
4、测试命令
venv) [root@virtul-test-xq aws]# mon-【tab】
mon-cmd mon-describe-alarms-for-metric.cmd mon-put-data
mon-cmd.cmd mon-disable-alarm-actions mon-put-data.cmd
mon-delete-alarms mon-disable-alarm-actions.cmd mon-put-metric-alarm
mon-delete-alarms.cmd mon-enable-alarm-actions mon-put-metric-alarm.cmd
mon-describe-alarm-history mon-enable-alarm-actions.cmd mon-set-alarm-state
mon-describe-alarm-history.cmd mon-get-stats mon-set-alarm-state.cmd
mon-describe-alarms mon-get-stats.cmd mon-version
mon-describe-alarms.cmd mon-list-metrics mon-version.cmd
mon-describe-alarms-for-metric mon-list-metrics.cmd
(venv) [root@virtul-test-xq aws]# mon-get-stats DatabaseConnections --dimensions="DBInstanceIdentifier=*******" --statistics= Average --namespace="AWS/RDS" --start-time 2017-06-21T09:00:00 --end-time 2017-06-21T12:00:00 --I ******** --S ******* --period 600
2017-06-21 09:00:00 30.0 Count
2017-06-21 09:10:00 30.0 Count
2017-06-21 09:20:00 30.0 Count
2017-06-21 09:30:00 29.1 Count
2017-06-21 09:40:00 29.0 Count
2017-06-21 09:50:00 29.0 Count
注意这里的时间参数:
The timestamp of the first datapoint to return, inclusive. For example,
2009-11-25T19:00:00+00:00Z. Timestamp will be rounded down to the nearest
minute. The dateTime type uses ISO 8601 (UTC). The default for this is 1
hour in the past.
参考连接:
Amazon RDS 指标
http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/CHAP_Monitoring.html#USER_Monitoring
Amazon RDS 指标和维度
http://docs.aws.amazon.com/zh_cn/AmazonCloudWatch/latest/monitoring/rds-metricscollected.html
boto3参考手册
https://boto3.readthedocs.io/en/latest/guide/cw-example-metrics.html
region地区查询
http://docs.aws.amazon.com/zh_cn/general/latest/gr/rande.html#cw_region
Amazon CloudWatch 工具下载
https://aws.amazon.com/items/2534
java下载地址
https://www.java.com/zh_CN/download/manual.jsp
一个不错的监控工具
https://app.datadoghq.com/account/settings#integrations
grafana监控aws
http://docs.grafana.org/features/datasources/cloudwatch/
PS:本文纯属记录个人实践经历,如有问题,可随时联系我。QQ505711559