Adding prometheus
This commit is contained in:
parent
ca62c2b026
commit
b7141fc8af
3 changed files with 28 additions and 0 deletions
|
|
@ -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
8
src/prometheus/module.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { Module } from '@nestjs/common'
|
||||
|
||||
import { PrometheusProvider } from './provider'
|
||||
|
||||
@Module({
|
||||
providers: [PrometheusProvider],
|
||||
})
|
||||
export class PrometheusModule {}
|
||||
18
src/prometheus/provider.ts
Normal file
18
src/prometheus/provider.ts
Normal 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' },
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue