mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
prometheus track playercounts
This commit is contained in:
1 parent
cf7af19370
commit
b7b0dd9d85
1 file changed
+11
@@ -95,6 +95,11 @@ const prometheusProductionGauge = new Prometheus.Gauge({
|
||||
help: 'Items produced by instance',
|
||||
labelNames: ["instanceID", "itemName"],
|
||||
});
|
||||
const prometheusPlayerCountGauge = new Prometheus.Gauge({
|
||||
name: prometheusPrefix+'player_count_gauge',
|
||||
help: 'Amount of players connected to this cluster',
|
||||
labelNames: ["instanceID", "instanceName"],
|
||||
})
|
||||
setInterval(()=>{
|
||||
let numberOfActiveSlaves = 0;
|
||||
for(let instance in slaves){
|
||||
@@ -112,6 +117,12 @@ app.get('/metrics', (req, res) => {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
let reqStartTime = Date.now();
|
||||
res.set('Content-Type', Prometheus.register.contentType);
|
||||
|
||||
// gather some static metrics
|
||||
for(let instanceID in slaves){try{
|
||||
prometheusPlayerCountGauge.labels(instanceID, slaves[instanceID].instanceName).set(slaves[instanceID].playerCount);
|
||||
}catch(e){}}
|
||||
|
||||
res.end(Prometheus.register.metrics());
|
||||
httpRequestDurationMilliseconds.labels(req.route.path).observe(Date.now()-reqStartTime);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user