You must have Python 2.7 installed.

Install pip

Skip this step if you already have pip or an alternative.

How to Install pip

CLI. Skip this step if it has been installed:

pip install aliyuncli
pip install -Iv aliyun-python-sdk-cms==5.0.0
aliyuncli configure

Instructions on installing CLI

Install cms-python-sdk dependencies:

pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-cms

Code example:

from aliyunsdkcore import client
from aliyunsdkcms.request.v20170301 import QueryMetricListRequest
import time
clt = client.AcsClient('your_access_key','your_access_secret','your_region_id')
request = QueryMetricListRequest.QueryMetricListRequest()
request.set_accept_format('json')
request.set_Project('acs_ecs_dashboard')
request.set_Metric('CPUUtilization')
start_time = "2016-10-25 10:00:00"
timestamp_start = int(time.mktime(time.strptime(start_time, "%Y-%m-%d %H:%M:%S"))) * 1000
request.set_StartTime(timestamp_start)
request.set_Dimensions("{'instanceId':'i-94g5hc378'}")
request.set_Period('60')
result = clt.do_action_with_exception(request)
print result