diff --git a/server/src/controllers/analytics_controller.ts b/server/src/controllers/analytics_controller.ts index 9edacdc..5b553da 100644 --- a/server/src/controllers/analytics_controller.ts +++ b/server/src/controllers/analytics_controller.ts @@ -369,6 +369,10 @@ export function isAnalyticReady(): boolean { return analyticsService.ready; } +export async function getActiveWebhooks() { + const analyticUnits = await AnalyticUnit.findMany({ alert: true }); + return analyticUnits.map(analyticUnit => analyticUnit.id); +} export async function createAnalyticUnitFromObject(obj: any): Promise { if(obj.datasource !== undefined) { diff --git a/server/src/index.ts b/server/src/index.ts index a7d3b22..bce00de 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -42,6 +42,9 @@ rootRouter.use('/panel', panelRouter.routes(), panelRouter.allowedMethods()); rootRouter.use('/threshold', thresholdRouter.routes(), thresholdRouter.allowedMethods()); rootRouter.get('/', async (ctx) => { + const activeWebhooks = await AnalyticsController.getActiveWebhooks(); + const activeWebhooksAmount = activeWebhooks.length; + ctx.response.body = { server: 'OK', analyticsReady: AnalyticsController.isAnalyticReady(), @@ -51,7 +54,8 @@ rootRouter.get('/', async (ctx) => { docker: process.env.INSIDE_DOCKER !== undefined, zmqConectionString: ZMQ_CONNECTION_STRING, serverPort: HASTIC_PORT, - git: GIT_INFO + git: GIT_INFO, + activeWebhooksAmount }; });