mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +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',
|
help: 'Websocket traffic',
|
||||||
labelNames: ["connectionType"],
|
labelNames: ["connectionType"],
|
||||||
});
|
});
|
||||||
|
const prometheusProductionGauge = new Prometheus.Gauge({
|
||||||
|
name: prometheusPrefix+'production_gauge',
|
||||||
|
help: 'Items produced by instance',
|
||||||
|
labelNames: ["instanceID", "itemName"],
|
||||||
|
});
|
||||||
setInterval(()=>{
|
setInterval(()=>{
|
||||||
let numberOfActiveSlaves = 0;
|
let numberOfActiveSlaves = 0;
|
||||||
for(let instance in slaves){
|
for(let instance in slaves){
|
||||||
@@ -608,6 +613,11 @@ app.post("/api/logStats", function(req,res) {
|
|||||||
timestamp: req.body.timestamp,
|
timestamp: req.body.timestamp,
|
||||||
data: req.body.data,
|
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);
|
console.log("inserted: " + req.body.instanceID + " | " + req.body.timestamp);
|
||||||
} else {
|
} else {
|
||||||
console.log("error invalid timestamp " + req.body.timestamp);
|
console.log("error invalid timestamp " + req.body.timestamp);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="terminal">
|
<div id="terminal">
|
||||||
<div class="titleBar">
|
<div class="titleBar" style="display:none;">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<p>Clusterio RCON shell</p>
|
<p>Clusterio RCON shell</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user