|
|
|
|
@ -12,17 +12,16 @@ const libCounter = new Prometheus.Counter({
|
|
|
|
|
help: 'A simple counter for app access during runtime created with unofficial prometheus nodejs library' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const libUptime = new Prometheus.Histogram({ |
|
|
|
|
const libUptime = new Prometheus.Counter({ |
|
|
|
|
name: 'lib_upTime', |
|
|
|
|
help: 'uptime A counter of the application\'s uptime in millisenconds.' |
|
|
|
|
help: 'uptime A counter of the application\'s uptime in seconds.' |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
libUptime.startTimer(); |
|
|
|
|
|
|
|
|
|
const collectDefaultMetrics = Prometheus.collectDefaultMetrics; |
|
|
|
|
// const collectDefaultMetrics = Prometheus.collectDefaultMetrics;
|
|
|
|
|
|
|
|
|
|
// Probe every 5th second.
|
|
|
|
|
collectDefaultMetrics({ timeout: 5000 }); |
|
|
|
|
// collectDefaultMetrics({ timeout: 5000 });
|
|
|
|
|
|
|
|
|
|
// new schema model object based on the structure of what I want to put on MongoDB collection
|
|
|
|
|
var testSchema = new Schema({ |
|
|
|
|
@ -48,9 +47,11 @@ app.get('/metrics', function(req, res){
|
|
|
|
|
// res.write('# HELP invocation_count A simple counter for app access during runtime' + '\n');
|
|
|
|
|
// res.write('# TYPE invocation_count counter'+ '\n');
|
|
|
|
|
// res.write('invocation_count ' + counter + '\n');
|
|
|
|
|
libUptime.inc(Math.floor(process.uptime())); |
|
|
|
|
res.set('Content-Type', Prometheus.register.contentType) |
|
|
|
|
res.end(Prometheus.register.metrics()) |
|
|
|
|
res.end(); |
|
|
|
|
libUptime.reset(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|