diff --git a/package-lock.json b/package-lock.json index 1445db05..83f6d816 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cht-user-management", - "version": "2.1.7", + "version": "2.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cht-user-management", - "version": "2.1.7", + "version": "2.1.8", "license": "ISC", "dependencies": { "@bull-board/api": "^5.17.0", diff --git a/package.json b/package.json index 38f78ae2..8214d286 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cht-user-management", - "version": "2.1.7", + "version": "2.1.8", "main": "dist/index.js", "dependencies": { "@bull-board/api": "^5.17.0", diff --git a/scripts/deploy/values/users-chis-civ.yaml b/scripts/deploy/values/users-chis-civ.yaml index fb993603..75fbea2e 100644 --- a/scripts/deploy/values/users-chis-civ.yaml +++ b/scripts/deploy/values/users-chis-civ.yaml @@ -5,7 +5,7 @@ cht-user-management: enabled: true image: repository: public.ecr.aws/medic/cht-user-management - tag: "2.1.7" # Set this to the version of the docker image + tag: "2.1.8" # Set this to the version of the docker image # Environment variablues to set in the pod, for example: # env: @@ -51,7 +51,7 @@ cht-user-management-worker: replicaCount: 1 image: repository: public.ecr.aws/medic/cht-user-management-worker - tag: "2.1.7" + tag: "2.1.8" env: NODE_ENV: production REDIS_HOST: users-chis-civ-redis-master.users-chis-prod.svc.cluster.local diff --git a/scripts/deploy/values/users-chis-ke.yaml b/scripts/deploy/values/users-chis-ke.yaml index 18889140..e67414d0 100644 --- a/scripts/deploy/values/users-chis-ke.yaml +++ b/scripts/deploy/values/users-chis-ke.yaml @@ -5,7 +5,7 @@ cht-user-management: enabled: true image: repository: public.ecr.aws/medic/cht-user-management - tag: "2.1.7" # Set this to the version of the docker image + tag: "2.1.8" # Set this to the version of the docker image # Environment variablues to set in the pod, for example: # env: @@ -51,7 +51,7 @@ cht-user-management-worker: replicaCount: 1 image: repository: public.ecr.aws/medic/cht-user-management-worker - tag: "2.1.7" + tag: "2.1.8" env: NODE_ENV: production REDIS_HOST: users-chis-ke-redis-master.users-chis-prod.svc.cluster.local diff --git a/scripts/deploy/values/users-chis-ml.yaml b/scripts/deploy/values/users-chis-ml.yaml index fe6fc1c9..e1e48ac4 100644 --- a/scripts/deploy/values/users-chis-ml.yaml +++ b/scripts/deploy/values/users-chis-ml.yaml @@ -5,7 +5,7 @@ cht-user-management: enabled: true image: repository: public.ecr.aws/medic/cht-user-management - tag: "2.1.7" # Set this to the version of the docker image + tag: "2.1.8" # Set this to the version of the docker image # Environment variablues to set in the pod, for example: # env: @@ -51,7 +51,7 @@ cht-user-management-worker: replicaCount: 1 image: repository: public.ecr.aws/medic/cht-user-management-worker - tag: "2.1.7" + tag: "2.1.8" env: NODE_ENV: production REDIS_HOST: users-chis-ml-redis-master.users-chis-prod.svc.cluster.local diff --git a/scripts/deploy/values/users-chis-tg.yaml b/scripts/deploy/values/users-chis-tg.yaml index 99e25ae2..35eeb8b2 100644 --- a/scripts/deploy/values/users-chis-tg.yaml +++ b/scripts/deploy/values/users-chis-tg.yaml @@ -5,7 +5,7 @@ cht-user-management: enabled: true image: repository: public.ecr.aws/medic/cht-user-management - tag: "2.1.7" # Set this to the version of the docker image + tag: "2.1.8" # Set this to the version of the docker image # Environment variablues to set in the pod, for example: # env: @@ -51,7 +51,7 @@ cht-user-management-worker: replicaCount: 1 image: repository: public.ecr.aws/medic/cht-user-management-worker - tag: "2.1.7" + tag: "2.1.8" env: NODE_ENV: production REDIS_HOST: users-chis-tg-redis-master.users-chis-prod.svc.cluster.local diff --git a/src/server.ts b/src/server.ts index bad26957..25b2e8c3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -16,10 +16,10 @@ import SessionCache from './services/session-cache'; import { checkRedisConnection } from './config/config-worker'; import { getChtConfQueue } from './lib/queues'; +const PROMETHEUS_ENDPOINT = '/metrics'; const UNAUTHENTICATED_ENDPOINTS = [ '/public/*', - '/fastify-metrics', - '/bullmq-metrics' + PROMETHEUS_ENDPOINT, ]; const build = (opts: FastifyServerOptions): FastifyInstance => { @@ -53,19 +53,25 @@ const build = (opts: FastifyServerOptions): FastifyInstance => { }); fastify.register(metricsPlugin, { - endpoint: '/fastify-metrics', + endpoint: PROMETHEUS_ENDPOINT, routeMetrics: { + registeredRoutesOnly: false, + groupStatusCodes: false, + methodBlacklist: ['HEAD', 'OPTIONS', 'TRACE'], + invalidRouteGroup: '__unknown__', enabled: { histogram: true, - summary: false + summary: true, } } }); - fastify.get('/bullmq-metrics', async (req, resp) => { - const promMetrics = await getChtConfQueue().bullQueue.exportPrometheusMetrics(); - resp.header('Content-Type', 'text/plain'); - resp.send(promMetrics); + // hijack the response from fastify-metrics appending additional metrics + fastify.addHook('onSend', async (request, reply, payload: string) => { + if (request.routerPath === PROMETHEUS_ENDPOINT) { + const bullmqMetrics = await getChtConfQueue().bullQueue.exportPrometheusMetrics(); + return payload + bullmqMetrics; + } }); Auth.assertEnvironmentSetup();