Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

perf(api): improve healthcheck a bit

Carl-Gerhard Lindesvärde348a6a12cbb
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index c6a003d6f..74c2da6c0 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -228,11 +228,15 @@ const startServer = async () => {
reply.send({ name: 'openpanel sdk api' });
});
fastify.get('/healthcheck', async (request, reply) => {
- const redisRes = await withTimings(getRedisCache().keys('*'));
+ const redisRes = await withTimings(
+ getRedisCache().keys('keys op:buffer:*'),
+ );
const dbRes = await withTimings(db.project.findFirst());
const queueRes = await withTimings(eventsQueue.getCompleted());
const chRes = await withTimings(
- chQuery(`SELECT * FROM ${TABLE_NAMES.events} LIMIT 1`),
+ chQuery(
+ `SELECT * FROM ${TABLE_NAMES.events} WHERE created_at > now() - INTERVAL 10 MINUTE LIMIT 1`,
+ ),
);
const status = redisRes && dbRes && queueRes && chRes ? 200 : 500;