AWS上獲取監控數據(EC2/RDS都支持)


方法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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM