mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Prometheus now tracks import/export statistics
This commit is contained in:
1 parent
f5e908eb5d
commit
f580f06064
1 file changed
+14
@@ -105,6 +105,16 @@ const prometheusProductionGauge = new Prometheus.Gauge({
|
|||||||
help: 'Items produced by instance',
|
help: 'Items produced by instance',
|
||||||
labelNames: ["instanceID", "itemName"],
|
labelNames: ["instanceID", "itemName"],
|
||||||
});
|
});
|
||||||
|
const prometheusExportGauge = new Prometheus.Gauge({
|
||||||
|
name: prometheusPrefix+'export_gauge',
|
||||||
|
help: 'Items exported by instance',
|
||||||
|
labelNames: ["instanceID", "itemName"],
|
||||||
|
});
|
||||||
|
const prometheusImportGauge = new Prometheus.Gauge({
|
||||||
|
name: prometheusPrefix+'import_gauge',
|
||||||
|
help: 'Items imported by instance',
|
||||||
|
labelNames: ["instanceID", "itemName"],
|
||||||
|
});
|
||||||
const prometheusPlayerCountGauge = new Prometheus.Gauge({
|
const prometheusPlayerCountGauge = new Prometheus.Gauge({
|
||||||
name: prometheusPrefix+'player_count_gauge',
|
name: prometheusPrefix+'player_count_gauge',
|
||||||
help: 'Amount of players connected to this cluster',
|
help: 'Amount of players connected to this cluster',
|
||||||
@@ -438,11 +448,13 @@ app.post("/api/place", authenticate.middleware, function(req, res) {
|
|||||||
key:req.body.name,
|
key:req.body.name,
|
||||||
value:req.body.count,
|
value:req.body.count,
|
||||||
});
|
});
|
||||||
|
prometheusExportGauge.labels(x.instanceID, req.body.name).inc(req.body.count);
|
||||||
// save items we get
|
// save items we get
|
||||||
db.items.addItem({
|
db.items.addItem({
|
||||||
name:req.body.name,
|
name:req.body.name,
|
||||||
count:req.body.count
|
count:req.body.count
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attempt confirming
|
// Attempt confirming
|
||||||
res.send("success");
|
res.send("success");
|
||||||
} else {
|
} else {
|
||||||
@@ -514,6 +526,8 @@ app.post("/api/remove", authenticate.middleware, function(req, res) {
|
|||||||
//console.log(sentItemStatistics.data)
|
//console.log(sentItemStatistics.data)
|
||||||
sentItemStatisticsBySlaveID[object.instanceID] = sentItemStatistics;
|
sentItemStatisticsBySlaveID[object.instanceID] = sentItemStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prometheusImportGauge.labels(object.instanceID, object.name).inc(object.count);
|
||||||
res.send({count: object.count, name: object.name});
|
res.send({count: object.count, name: object.name});
|
||||||
httpRequestDurationMilliseconds.labels(req.route.path).observe(Date.now()-reqStartTime);
|
httpRequestDurationMilliseconds.labels(req.route.path).observe(Date.now()-reqStartTime);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user