Skip to content

Commit 59badc4

Browse files
committed
feat: prometheus
1 parent 1e57a93 commit 59badc4

File tree

12 files changed

+14185
-17914
lines changed

12 files changed

+14185
-17914
lines changed

apps/api-gateway/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SubmissionsController } from './controllers/submissions/submissions.con
1212
import { EventsGateway } from './gateways/events.gateway';
1313
import { BullModule } from '@nestjs/bullmq';
1414
import { NotificationConsumer } from './workers/notification.worker';
15+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
1516

1617
@Module({
1718
imports: [
@@ -109,6 +110,7 @@ import { NotificationConsumer } from './workers/notification.worker';
109110
BullModule.registerQueue({
110111
name: 'notifications-queue',
111112
}),
113+
PrometheusModule.register(),
112114
],
113115
controllers: [
114116
UsersController,

apps/auth-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MailModule } from './mail/mail.module';
44
import { ConfigModule } from '@nestjs/config';
55
import { configuration, validate } from '@leetcode/config';
66
import { DatabaseModule } from '@leetcode/database';
7+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
78

89
@Module({
910
imports: [
@@ -17,6 +18,7 @@ import { DatabaseModule } from '@leetcode/database';
1718
DatabaseModule,
1819
AuthModule,
1920
MailModule,
21+
PrometheusModule.register(),
2022
],
2123
controllers: [],
2224
providers: [],

apps/companies-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DatabaseModule } from '@leetcode/database';
33
import { Module } from '@nestjs/common';
44
import { ConfigModule } from '@nestjs/config';
55
import { CompaniesController } from './companies/companies.controller';
6+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
67

78
@Module({
89
imports: [
@@ -14,6 +15,7 @@ import { CompaniesController } from './companies/companies.controller';
1415
validate,
1516
}),
1617
DatabaseModule,
18+
PrometheusModule.register(),
1719
],
1820
controllers: [CompaniesController],
1921
providers: [],

apps/execution-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Configuration, configuration, validate } from '@leetcode/config';
55
import { DatabaseModule } from '@leetcode/database';
66
import { ExecutionConsumer } from './execution/execution.worker';
77
import { BullModule } from '@nestjs/bullmq';
8+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
89

910
@Module({
1011
imports: [
@@ -32,6 +33,7 @@ import { BullModule } from '@nestjs/bullmq';
3233
BullModule.registerQueue({
3334
name: 'results-queue',
3435
}),
36+
PrometheusModule.register(),
3537
],
3638
controllers: [],
3739
providers: [ExecutionService, ExecutionConsumer],

apps/problems-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DatabaseModule } from '@leetcode/database';
44
import { ConfigModule } from '@nestjs/config';
55
import { configuration, validate } from '@leetcode/config';
66
import { ProblemsService } from './problems/problems.service';
7+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
78

89
@Module({
910
imports: [
@@ -15,6 +16,7 @@ import { ProblemsService } from './problems/problems.service';
1516
validate,
1617
}),
1718
DatabaseModule,
19+
PrometheusModule.register(),
1820
],
1921
controllers: [ProblemsController],
2022
providers: [ProblemsService],

apps/submissions-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
55
import { Configuration, configuration, validate } from '@leetcode/config';
66
import { BullModule } from '@nestjs/bullmq';
77
import { ResultsConsumer } from './submissions/submissions.worker';
8+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
89

910
@Module({
1011
imports: [
@@ -32,6 +33,7 @@ import { ResultsConsumer } from './submissions/submissions.worker';
3233
BullModule.registerQueue({
3334
name: 'notifications-queue',
3435
}),
36+
PrometheusModule.register(),
3537
],
3638
controllers: [SubmissionsController],
3739
providers: [ResultsConsumer],

apps/tags-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DatabaseModule } from '@leetcode/database';
33
import { Module } from '@nestjs/common';
44
import { ConfigModule } from '@nestjs/config';
55
import { TagsController } from './tags/tags.controller';
6+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
67

78
@Module({
89
imports: [
@@ -14,6 +15,7 @@ import { TagsController } from './tags/tags.controller';
1415
validate,
1516
}),
1617
DatabaseModule,
18+
PrometheusModule.register(),
1719
],
1820
controllers: [TagsController],
1921
providers: [],

apps/users-service/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { UsersController } from './users/users.controller';
33
import { DatabaseModule } from '@leetcode/database';
44
import { ConfigModule } from '@nestjs/config';
55
import { configuration, validate } from '@leetcode/config';
6+
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
67

78
@Module({
89
imports: [
@@ -14,6 +15,7 @@ import { configuration, validate } from '@leetcode/config';
1415
validate,
1516
}),
1617
DatabaseModule,
18+
PrometheusModule.register(),
1719
],
1820
controllers: [UsersController],
1921
providers: [],

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,17 @@ services:
329329
# - NODE_ENV=production
330330
# - VITE_API_ENDPOINT=http://api-gateway:5000
331331

332+
# =======================================
333+
# PROMETHEUS + GRAFANA + LOKI
334+
# =======================================
335+
336+
prometheus-server:
337+
image: prom/prometheus
338+
ports:
339+
- 9090:9090
340+
volumes:
341+
- ./prometheus.yml:/etc/prometheus/prometheus.yml
342+
332343
volumes:
333344
pgdata:
334345
redis-data:

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
},
2121
"dependencies": {
2222
"@nestjs/microservices": "^11.1.8",
23+
"@willsoto/nestjs-prometheus": "^6.0.2",
2324
"dotenv": "^17.2.3",
24-
"dotenv-cli": "^11.0.0"
25+
"dotenv-cli": "^11.0.0",
26+
"prom-client": "^15.1.3"
2527
}
2628
}

0 commit comments

Comments
 (0)