Closed rouralberto closed 5 years ago
@roura356a tencentcloud-sdk-nodejs is a SDK for Tencent Cloud API 3.0 (with endpoint .tencentcloudapi.com), the document you referred is Tencent Cloud API 2.0 (with endpoint .api.qcloud.com/v2/index.php). Since they are not compatible, you cannot get what you want with API 2.0 parameters while calling API 3.0 interface.
There is a tool, named API Explorer, which can be used to get familiar with API 3.0, while generating simple SDK source code, for this particular interface, please refer to: https://console.cloud.tencent.com/api/explorer?Product=monitor&Version=2018-07-24&Action=GetMonitorData&SignVersion=
here is the source code I generated with the tool, you can adjust the parameters according to you purpose:
const tencentcloud = require("../../../../tencentcloud-sdk-nodejs");
const MonitorClient = tencentcloud.monitor.v20180724.Client;
const models = tencentcloud.monitor.v20180724.Models;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
let cred = new Credential("masked-secret-id", "masked-secret-key");
let httpProfile = new HttpProfile();
httpProfile.endpoint = "monitor.tencentcloudapi.com";
let clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
let client = new MonitorClient(cred, "ap-guangzhou", clientProfile);
let req = new models.GetMonitorDataRequest();
let params = '{"Namespace":"QCE/CVM","MetricName":"CPUUsage","Instances":[{"Dimensions":[{"Name":"InstanceId","Value":"ins-oxbabxrc"}]}]}'
req.from_json_string(params);
client.GetMonitorData(req, function(errMsg, response) {
if (errMsg) {
console.log(errMsg);
return;
}
console.log(response.to_json_string());
});
The document you need to read is https://cloud.tencent.com/document/product/248/30385 , unfortunately it is Chinese simplified only.
Ohh got it, @zqfan! Thank you so much for the clarification. I'm still quite new with Tencent Cloud. I'll be more aware from now on about this differences 👍
Sadly the Api Explorer is locked to the Chinese portal and I can't access with my international login.
I thought it just doesn't support English. International account is different, I think the support will not be soon.
Hi, I'm using this SDK to get monitor data of CVM instances and I've been unable to form a working query. So far I'm getting an error when following instructions here.
I opened the source code of the Models for monitor and then formed an
Instances
array with aDimensions
array inside. No luck either. I get aError: Param dimensions error
This is where I am now:
I'd love to get an example of how to query it.