Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit ca0034e

Browse files
committed
fix duplicate metrics
1 parent a87d664 commit ca0034e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless/aws-sdk",
3-
"version": "6.1.1",
3+
"version": "6.1.2",
44
"description": "Powerful Serverless Utilities",
55
"main": "src/index.js",
66
"author": "Serverless, Inc.",

src/getMetrics.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module.exports = async (
1616
* Validate parameters
1717
*/
1818

19-
rangeStart = rangeStart || moment().utc().toISOString()
20-
rangeEnd = rangeEnd || moment().utc().subtract(1, 'days').toISOString()
19+
rangeStart = rangeStart || moment.utc().toISOString()
20+
rangeEnd = rangeEnd || moment.utc().subtract(1, 'days').toISOString()
2121
resources = resources || []
2222

2323
// Ensure resources were submitted
@@ -142,8 +142,6 @@ module.exports = async (
142142
throw new Error(`Your AWS Cloudwatch query contains ${cloudwatchMetricQueries.length} queries, but Cloudwatch can only support up to 500 queries.`)
143143
}
144144

145-
console.log(cloudwatchMetricQueries)
146-
147145
// Prepare CloudWatch queries
148146
const params = {
149147
StartTime: rangeStart.unix(),
@@ -185,19 +183,19 @@ module.exports = async (
185183
// Add data which Cloudwatch has returned by inspecting timestamps of CW's returned data
186184
// If a timestamp exists that matches one of the defaults, add it in.
187185
metric.xData.forEach((xVal, i2) => {
188-
if (moment(xVal).isSame(cwVal)) {
186+
if (moment.utc(xVal).isSame(cwVal)) {
189187
metric.yDataSets[0].yData[i2] = cwMetric.Values[i];
190188
}
191189
});
190+
});
192191

193-
// Transform data
194-
Object.keys(resourcesUsed).forEach((resourceType) => {
195-
metric = resourceHandlers[resourceType].transforms(cwMetric, metric)
196-
})
192+
// Transform data
193+
Object.keys(resourcesUsed).forEach((resourceType) => {
194+
metric = resourceHandlers[resourceType].transforms(cwMetric, metric)
195+
})
197196

198-
// Add to results
199-
result.metrics.push(metric)
200-
});
197+
// Add to results
198+
result.metrics.push(metric)
201199
})
202200

203201
return result;

0 commit comments

Comments
 (0)