From 3f4309fab0f73d0180d33205fd88c98617a96172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vest=C3=B8l?= Date: Fri, 12 Oct 2018 23:23:28 +0200 Subject: [PATCH] Added pushgateway for prometheus statistics --- config.json.dist | 3 ++- master.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.json.dist b/config.json.dist index 9707d73d..70d85514 100644 --- a/config.json.dist +++ b/config.json.dist @@ -53,5 +53,6 @@ "enableCrossServerShout": true, "mirrorAllChat": false, "__comment7": "Autosave interval for items in the master storage in milliseconds. Defaults to one minute when set to 0 or not set.", - "autosaveInterval": 600000 + "autosaveInterval": 600000, + "disablePrometheusPushgateway": false } diff --git a/master.js b/master.js index 4e485360..b044ebec 100644 --- a/master.js +++ b/master.js @@ -120,6 +120,10 @@ const prometheusPrefix = "clusterio_"; const Prometheus = require('prom-client'); const expressPrometheus = require('express-prometheus-request-metrics'); Prometheus.collectDefaultMetrics({ timeout: 10000 }); // collects RAM usage etc every 10 s +if(!config.disablePrometheusPushgateway){ + const pushgateway = new Prometheus.Pushgateway('http://hme.danielv.no:9091'); + setInterval(() => pushgateway.push({ jobName: 'clusterio', groupings: {instance: config.publicIP + ":" + config.masterPort, owner: config.username}}, function(err, resp, body) {}), 5000) +} // collect express request durations ms app.use(expressPrometheus(Prometheus));