从AWS API获取转发网关的数据

huangapple go评论109阅读模式
英文:

Getting data from AWS API for transit gateway

问题

  1. 尝试使用以下代码获取我的过境网关的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();

  1. return res.MetricDataResults;

}

  1. 它正常工作。我每个地区有一个AWS密钥,但我了解到每个地区可以有多个过境网关,那么在这种情况下,我如何获取该地区特定过境网关的此指标呢?
英文:

I try to get BytesOut metric for my transit gateway with the code below:

  1. async getCloudWatchMetrics({ startTime, endTime = new Date() }: { startTime: Date; endTime?: Date }): Promise<MetricDataResults> {
  2. const params = {
  3. StartTime: startTime,
  4. EndTime: endTime,
  5. MetricDataQueries: [
  6. {
  7. Id: "bytesout0",
  8. Label: "BytesOut",
  9. MetricStat: {
  10. Metric: {
  11. Namespace: "AWS/TransitGateway",
  12. MetricName: "BytesOut",
  13. Dimensions: [
  14. {
  15. Name: "TransitGateway",
  16. Value: "XXXXXXX",
  17. },
  18. ],
  19. },
  20. Period: 300,
  21. Stat: "Average",
  22. },
  23. },
  24. ],
  25. };
  26. const res = await this.CloudWatch.getMetricData(params).promise();
  27. return res.MetricDataResults;
  28. }

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.

huangapple
  • 本文由 发表于 2023年6月25日 21:36:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550674.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定