forked from alertlogic/al-aws-collector-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistics.js
44 lines (39 loc) · 1.18 KB
/
statistics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* -----------------------------------------------------------------------------
* @copyright (C) 2018, Alert Logic, Inc
* @doc
*
* Statistics functions common for all collectors
*
* @end
* -----------------------------------------------------------------------------
*/
const AWS = require('aws-sdk');
const async = require('async');
const m_alAws = require('./al_aws');
const m_alStatsTmpls = require('./statistics_templates');
function getStatistics(context, statsFuns, callback) {
allFuns = [
function(asyncCallback) {
return m_alStatsTmpls.getLambdaMetrics(
context.functionName, 'Invocations', asyncCallback
);
},
function(asyncCallback) {
return m_alStatsTmpls.getLambdaMetrics(
context.functionName, 'Errors', asyncCallback
);
}
].concat(statsFuns);
async.parallel(allFuns,
function(err, response) {
if (err) {
return callback(null, {statistics : []});
} else {
return callback(null, {statistics : response});
}
}
);
}
module.exports = {
getStatistics : getStatistics
};