We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20eb28a commit d3007a5Copy full SHA for d3007a5
packages/server/utils/metrics.ts
@@ -22,7 +22,11 @@ export function createMetricsRegistry(ctx: Context) {
22
23
createMetric(Gauge, 'xcpc_machinecount', 'machinecount', {
24
async collect() {
25
- this.set({}, await ctx.db.monitor.count({ updateAt: { $gt: new Date().getTime() - 120 * 1000 } }));
+ const machines = await ctx.db.monitor.find({});
26
+ const onlines = machines.filter((m) => m.updateAt > new Date().getTime() - 1000 * 60);
27
+ this.set({ type: 'total' }, machines.length);
28
+ this.set({ type: 'online' }, onlines.length);
29
+ this.set({ type: 'offline' }, machines.length - onlines.length);
30
},
31
});
32
0 commit comments