安装nodejs 和 npm。

示例代码

var Metrics = require("aliyun-metrics")

var client=new Metrics({
        accesskeyId: "your_accesskey_id",
        accesskeySecret: "your_accesskey_secret"
})

client.queryData({
        project:"acs_rds",
        metric:"CpuUsage",
        period:300,
        startTime:"2016-03-08T07:20:00Z",
        endTime:"2016-03-08T09:20:00Z",
        dimensions:"{instanceId:'your_instanceId'}"
}, function(error, data){
        if (error)
                console.log(error)
        else if (!data)
                console.log("data is null")
        else
                console.log(data)
});