英文:
Getting data from AWS API for transit gateway
问题
尝试使用以下代码获取我的过境网关的BytesOut指标:
async getCloudWatchMetrics({ startTime, endTime = new Date() }: { startTime: Date; endTime?: Date }): Promise
const params = {
StartTime: startTime,
EndTime: endTime,
MetricDataQueries: [
{
Id: "bytesout0",
Label: "BytesOut",
MetricStat: {
Metric: {
Namespace: "AWS/TransitGateway",
MetricName: "BytesOut",
Dimensions: [
{
Name: "TransitGateway",
Value: "XXXXXXX",
},
],
},
Period: 300,
Stat: "Average",
},
},
],
};
const res = await this.CloudWatch.getMetricData(params).promise();
return res.MetricDataResults;
}
它正常工作。我每个地区有一个AWS密钥,但我了解到每个地区可以有多个过境网关,那么在这种情况下,我如何获取该地区特定过境网关的此指标呢?
英文:
I try to get BytesOut metric for my transit gateway with the code below:
async getCloudWatchMetrics({ startTime, endTime = new Date() }: { startTime: Date; endTime?: Date }): Promise<MetricDataResults> {
const params = {
StartTime: startTime,
EndTime: endTime,
MetricDataQueries: [
{
Id: "bytesout0",
Label: "BytesOut",
MetricStat: {
Metric: {
Namespace: "AWS/TransitGateway",
MetricName: "BytesOut",
Dimensions: [
{
Name: "TransitGateway",
Value: "XXXXXXX",
},
],
},
Period: 300,
Stat: "Average",
},
},
],
};
const res = await this.CloudWatch.getMetricData(params).promise();
return res.MetricDataResults;
}
It works fine. I have one AWS key per region but as I understand there can be multiple transit gateways per region and in that case, how can I get this metric for a specific transit gateway in that region?
答案1
得分: 0
请求中的Value字段是中转网关的ID,因此它将返回该特定中转网关的数据。
英文:
Value field in the request is the ID of the transit gateway so It will return data for that specific transit gateway.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论