I need to get a sum of MB sent to a bunch of Cloudwatch log groups as data, not in the console. But first I need to get sums for two working.
I started with an AWS support article. Then I grabbed the metric names I needed from the Cloudwatch console. Then looked at the docs for the get-metric-data
CLI.
Between the three this was the closest I got:
aws cloudwatch get-metric-data --profile default --metric-data-queries file://./.temp/metric-data-queries.json \
--start-time 2019-12-04T00:00:00Z --end-time 2019-12-18T00:00:00Z
Where the query file looks like this:
[
{
"Id": "mbSum",
"MetricStat": {
"Metric": {
"Namespace": "AWS/Logs",
"MetricName": "IncomingBytes",
"Dimensions": [
{
"Name": "LogGroupName",
"Value": "/aws/lambda/prd-***-lambda"
},
{
"Name": "LogGroupName",
"Value": "/aws/lambda/prd-****-lambda"
}
... 98 more, down the road, but just two for now
]
},
"Period": 1209600,
"Stat": "Sum",
"Unit": "Megabytes"
}
}
]
The result I got was:
{
"MetricDataResults": [
{
"Id": "mbSum",
"Label": "IncomingBytes",
"Timestamps": [],
"Values": [],
"StatusCode": "Complete"
}
],
"Messages": []
}
I'd expect a zero in there if there were no results. Tried with a period of 300 (like the get-metric-data
doc suggests), no change. The information I have regarding period is contradictory/unclear. What am I missing here?