Adding prometheus

This commit is contained in:
collin 2026-06-16 15:06:06 +02:00
parent ca62c2b026
commit b7141fc8af
No known key found for this signature in database
3 changed files with 28 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import { DatabaseLoggerService } from './logger/service.database_logger'
import { MembersModule } from './members/module'
import { MonitoringModule } from './monitoring/module'
import { NtfyModule } from './ntfy/module'
import { PrometheusModule } from './prometheus/module'
import { RecurringReservationsModule } from './recurringReservations/module'
import { ReservationsModule } from './reservations/module'
import { RunnerModule } from './runner/module'
@ -63,6 +64,7 @@ import { WaitingListModule } from './waitingList/module'
WaitingListModule,
NtfyModule,
MonitoringModule,
PrometheusModule,
],
})
export class AppModule implements NestModule {

8
src/prometheus/module.ts Normal file
View file

@ -0,0 +1,8 @@
import { Module } from '@nestjs/common'
import { PrometheusProvider } from './provider'
@Module({
providers: [PrometheusProvider],
})
export class PrometheusModule {}

View file

@ -0,0 +1,18 @@
import { OnApplicationBootstrap } from '@nestjs/common'
import { collectDefaultMetrics, Registry } from 'prom-client'
export class PrometheusProvider implements OnApplicationBootstrap {
private readonly registry: Registry
constructor() {
this.registry = new Registry()
}
onApplicationBootstrap() {
collectDefaultMetrics({
register: this.registry,
prefix: 'autobaan_',
labels: { GIT_COMMIT: process.env.GIT_COMMIT ?? 'unknown' },
})
}
}