diff --git a/Dockerfile b/Dockerfile index 30643eb..9b65cb0 100755 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM node WORKDIR /app # Copying npm config file setting npm repository location. -COPY .npmrc .npmrc +# COPY .npmrc .npmrc # If you add the package.json first and run npm install later, # Docker won’t have to install the dependencies again if you diff --git a/app.js b/app.js index b57350f..cee3ace 100755 --- a/app.js +++ b/app.js @@ -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(); });