'cannot get cloudwatch metric data with getMetricStatistics
I currently have a node application where I am trying to use the getMetricStatistics
function of the AWS Cloudwatch sdk to retrieve data from a metric into my application.
In order to troubleshoot this I have run the listMetrics
function as follows:
var params = {
MetricName: 'Open',
Namespace: 'AWS/SES',
};
cloudwatch.listMetrics(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
After running the above code, I get output written via console.log:
After this I try to run the getMetricStatistics
function as follows:
var cloudwatch = new aws.CloudWatch({apiVersion: '2010-08-01'});
var params = {
EndTime: new Date(2022,1,31), /* required */
MetricName: 'Open', /* required */
Namespace: 'AWS/SES', /* required */
Period: '3600', /* required */
StartTime: new Date(2022,1,27), /* required */
Dimensions: [
{
Name: 'test-open-key', /* required */
Value: 'test-open-value' /* required */
}
/* more items */
],
Statistics: [
'Average',
/* more items */
]
};
cloudwatch.getMetricStatistics(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
However, the output of the above code is as follows, showing no datapoints:
I have based my input parameters based on what I got from listMetrics
, and in my console I can see the following graph, meaning there should be at least one datapoint retrieved on the 29th January.
Would anyone be able to advise on what I'm doing wrong/any further avenues for troubleshooting?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|