Skip to content

Commit

Permalink
reformatted backend for ES 7
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Aiello <lorenzo@aiello.family>
  • Loading branch information
lorenzoaiello committed Mar 24, 2020
1 parent 8608b4f commit 75b5770
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 259 deletions.
76 changes: 38 additions & 38 deletions lib/default_format.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
const counters = function (key, value, ts, bucket) {
if (value) {
bucket.push({
"name": key,
"val":value,
"@timestamp": ts
});
return 1;
}
if (value) {
bucket.push({
"name": key,
"val": value,
"@timestamp": ts
});
return 1;
}

return 0;
}
return 0;
};

const timers = function (key, series, ts, bucket) {
let counter = 0;
for (keyTimer in series) {
if (series[keyTimer]) {
bucket.push({
"name": key,
"val":series[keyTimer],
"@timestamp": ts
});
counter ++;
let counter = 0;
for (let keyTimer in series) {
if (series[keyTimer]) {
bucket.push({
"name": key,
"val": series[keyTimer],
"@timestamp": ts
});
counter++;
}
}
}
return counter;
}
return counter;
};

const timer_data = function (key, value, ts, bucket) {
value["@timestamp"] = ts;
value["name"] = key;
let shouldPush = false;
if (value['histogram']) {
for (var keyH in value['histogram']) {
shouldPush = shouldPush || !!value['histogram'][keyH];
value[keyH] = value['histogram'][keyH];
value["@timestamp"] = ts;
value["name"] = key;
let shouldPush = false;
if (value['histogram']) {
for (var keyH in value['histogram']) {
shouldPush = shouldPush || !!value['histogram'][keyH];
value[keyH] = value['histogram'][keyH];
}
delete value['histogram'];
}
delete value['histogram'];
}

if (shouldPush) {
bucket.push(value);
}
}
if (shouldPush) {
bucket.push(value);
}
};

exports.counters = counters;
exports.timers = timers;
exports.counters = counters;
exports.timers = timers;
exports.timer_data = timer_data;
exports.gauges = counters;
exports.gauges = counters;
Loading

0 comments on commit 75b5770

Please sign in to comment.