Skip to content

Commit

Permalink
Merge pull request #1 from statful/fix-multiple-namespaces-ingestion
Browse files Browse the repository at this point in the history
fix(NA): fix on multiple namespaces ingestion. fix on dimensions filtering.
  • Loading branch information
mistic authored Oct 6, 2016
2 parents 7cef26d + 2f1e846 commit 8e2e2dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "statful-collector-aws",
"version": "1.0.0",
"version": "1.0.1",
"description": "AWS Cloudwatch collector for Statful",
"engines": {
"node": ">=4.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class Collector {
if (!this.isStopping) {
let now = new Date();
let nowMinusPastPeriod = new Date(new Date(now).setSeconds(now.getSeconds() - (this[_config].statfulCollectorAws.period - 1)));

now.setMinutes(now.getMinutes() - 5);
nowMinusPastPeriod.setMinutes(nowMinusPastPeriod.getMinutes() - 5);

let startTime = nowMinusPastPeriod.toISOString();
let endTime = now.toISOString();

Expand Down
21 changes: 15 additions & 6 deletions src/metrics-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ class MetricsList {
if (validDimensions[i].length !== dimension.length) {
break;
}
valid = this[_dimensionsElementContainsAnother](validDimensions[i], dimension);

if (this[_dimensionsElementContainsAnother](validDimensions[i], dimension)) {
valid = true;
break;
}
}
return valid;
}
Expand All @@ -196,14 +200,19 @@ class MetricsList {
// Process dimensions information
each(requestData.data,
(metric, eachMetricCallback) => {
if (!this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.MetricName]) {
this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.MetricName] = [];
if (!this[_dimensionsValidatorPerRegionAndMetric][metricRegion].hasOwnProperty(metric.Namespace)) {
this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace] = {};
}

let validMetricDimensions = this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.MetricName];
if (!this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace][metric.MetricName]) {
this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace][metric.MetricName] = [];
}

let validMetricDimensions = this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace][metric.MetricName];
let dimensionsToInsert = this[_getDimensionsNames](metric.Dimensions);

this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.MetricName] =

this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace][metric.MetricName] =
this[_addDimensionsElement](dimensionsToInsert, validMetricDimensions);

eachMetricCallback(null);
Expand All @@ -230,7 +239,7 @@ class MetricsList {
// Validate dimensions to use with generated dimensions information
each(requestData.data,
(metric, eachMetricCallback) => {
let validDimensions = this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.MetricName];
let validDimensions = this[_dimensionsValidatorPerRegionAndMetric][metricRegion][metric.Namespace][metric.MetricName];
let dimensionsToVerify = this[_getDimensionsNames](metric.Dimensions);

if (this[_isAValidDimension](validDimensions, dimensionsToVerify)) {
Expand Down

0 comments on commit 8e2e2dc

Please sign in to comment.