mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Export production stats to prometheus
This commit is contained in:
1 parent
2b5cbf00e4
commit
4d5b3b855c
2 files changed
+11
-1
No files matched your search
@@ -90,6 +90,11 @@ const prometheusWsUsageCounter = new Prometheus.Counter({
|
||||
help: 'Websocket traffic',
|
||||
labelNames: ["connectionType"],
|
||||
});
|
||||
const prometheusProductionGauge = new Prometheus.Gauge({
|
||||
name: prometheusPrefix+'production_gauge',
|
||||
help: 'Items produced by instance',
|
||||
labelNames: ["instanceID", "itemName"],
|
||||
});
|
||||
setInterval(()=>{
|
||||
let numberOfActiveSlaves = 0;
|
||||
for(let instance in slaves){
|
||||
@@ -608,6 +613,11 @@ app.post("/api/logStats", function(req,res) {
|
||||
timestamp: req.body.timestamp,
|
||||
data: req.body.data,
|
||||
});
|
||||
try{
|
||||
Object.keys(req.body.data).forEach(itemName => {
|
||||
prometheusProductionGauge.labels(req.body.instanceID, itemName).inc(Number(req.body.data[itemName]) || 0);
|
||||
});
|
||||
}catch(e){console.log(e)};
|
||||
console.log("inserted: " + req.body.instanceID + " | " + req.body.timestamp);
|
||||
} else {
|
||||
console.log("error invalid timestamp " + req.body.timestamp);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
</div>
|
||||
<div id="terminal">
|
||||
<div class="titleBar">
|
||||
<div class="titleBar" style="display:none;">
|
||||
<div class="title">
|
||||
<p>Clusterio RCON shell</p>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user