Reputation: 2859
I'm making some calls to the AmazonCloudWatch api and can successfully receiving data back using the GetMetricDataAsync
and ListMetricsAsync
calls. However the data returned does not include what unit that data actually is.
For example: Bytes or Percent
Without the Units, I'm unable to meaningfully display the collect data.
Side note: I'm using the C# SDK.
Is it possible to retrieve the Units for the Metrics data?
{
"id": "q21",
"label": "DiskWriteBytes",
"messages": [],
"statusCode": {
"value": "PartialData"
},
"timestamps": ["2019-01-14T14:58:00+00:00", "2019-01-14T14:53:00+00:00", "2019-01-14T14:48:00+00:00"],
"values": [0.0, 0.0, 0.0]
}, {
"id": "q22",
"label": "NetworkIn",
"messages": [],
"statusCode": {
"value": "PartialData"
},
"timestamps": ["2019-01-14T14:58:00+00:00", "2019-01-14T14:53:00+00:00", "2019-01-14T14:48:00+00:00"],
"values": [21136.0, 21556.8, 20118.6]
}, {
Upvotes: 0
Views: 950
Reputation: 12109
By the looks of the example response, you're using the GetMetricData API. GetMetricData API will not return the unit, see here for the response data structure: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDataResult.html
If you set the unit in the request, API will filter by the unit, so any data returned will be with the unit requested.
If you don't set the unit and data exists with multiple units, message will be returned stating which units were found.
If you don't know the unit upfront and need to get it from the data, you can use GetMetricStatistics API, which will return the unit: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricStat.html
Upvotes: 1