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

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

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.

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:

确定