forked from DispatchBot/statsd-elasticsearch-backend
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lorenzo Aiello <lorenzo@aiello.family>
- Loading branch information
1 parent
8608b4f
commit 75b5770
Showing
3 changed files
with
185 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.