From abf6b9af82cc00f32251d48b4c8541e9a34cc49036ab7515d1fa39a60f65cefa Mon Sep 17 00:00:00 2001 From: localhorst Date: Thu, 16 Jan 2025 21:50:00 +0100 Subject: [PATCH] add metric TTN Uplinks --- server/src/controller/metricsController.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/controller/metricsController.ts b/server/src/controller/metricsController.ts index 74edcef..69f12bc 100644 --- a/server/src/controller/metricsController.ts +++ b/server/src/controller/metricsController.ts @@ -3,10 +3,12 @@ import { container } from "tsyringe"; import { Counter, Gauge, collectDefaultMetrics, register } from "prom-client"; import { LocationService } from "../services/locationService"; import { WifiLocationService } from "../services/wifiLocationService"; +import { TtnGatewayReceptionService } from "../services/ttnGatewayReceptionService"; const router = express.Router(); const locationService = container.resolve(LocationService); const wifiLocationService = container.resolve(WifiLocationService); +const ttnGatewayReceptionService = container.resolve(TtnGatewayReceptionService); // Collect default system metrics (e.g., CPU, memory usage) const prefix = 'locationhub_'; @@ -43,6 +45,12 @@ const wifiLocationRequestLimitExceeded = new Gauge({ labelNames: ["database"], }); +const ttnGatewayReceptions = new Gauge({ + name: `${prefix}ttn_gateway_receptions`, + help: "Total number of TTN Gateway receptions entries in database", + labelNames: ["database"], +}); + // Define the metrics endpoint router.get("/", async (req: Request, res: Response) => { @@ -53,6 +61,7 @@ router.get("/", async (req: Request, res: Response) => { wifiLocationTotal.set((await wifiLocationService.getAllWifiLocations()).length); wifiLocationNotResolvable.set((await wifiLocationService.getAllWifiLocationsByNotResolvable()).length); wifiLocationRequestLimitExceeded.set((await wifiLocationService.getAllWifiLocationsByRequestLimitExceeded()).length); + ttnGatewayReceptions.set((await ttnGatewayReceptionService.getAllGatewayReceptions()).length); // Increment the counter with labels requestCounter.inc({ method: req.method, route: req.route.path, status: 200 });