-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add prometheus metrics #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jgryffindor
wants to merge
9
commits into
liftedinit:main
Choose a base branch
from
jgryffindor:feat/prometheus
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add monitoring service, module and controller - Add custom registry and type definitions for adding counters, gauges with labels and custom functions to retrieve values - Add middleware for monitoring updates when /monitoring/metrics route is called - Add mfx power conversion metric to monitoring service
fmorency
approved these changes
May 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
private readonly logger = new Logger(MonitoringController.name); | ||
|
||
constructor() { | ||
// Initialie the Prometheus registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
// Initialie the Prometheus registry | |
//Initialize the Prometheus registry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new monitoring and metrics system using the
prom-client
library, adding metrics collection and exposing a/monitoring/metrics
endpoint.Monitoring and Metrics System Integration:
Dependency Addition: Added
prom-client
as a new dependency inserver/package.json
to enable Prometheus metrics collection.Monitoring 8000 Module: Introduced a new
MonitoringModule
inserver/src/metrics/monitoring/monitoring.module.ts
, which includes:MonitoringService
to define and update custom metrics. [1] [2]MonitoringController
to expose a/monitoring/metrics
endpoint for Prometheus scraping.MonitoringMiddleware
to ensure metrics are updated before serving the metrics endpoint.Application Module Updates:
Module Imports: Updated
server/src/app.module.ts
to import and register theMonitoringModule
and the Prometheus integration module (@willsoto/nestjs-prometheus
). [1] [2]Metrics Module Updates: Modified
server/src/metrics/metrics.module.ts
to include theMonitoringModule
as a dependency, allowing it to integrate with existing metrics functionality.New Dependencies for Monitoring
prom-client
dependencies inserver/package.json
to enable Prometheus metrics collection and integration. [1] [2]Monitoring Module Implementation
MonitoringModule
inserver/src/metrics/monitoring/monitoring.module.ts
, which includes middleware, a service, and a controller for handling metrics. The module integrates with existing entities likeMetric
andPrometheusQuery
.Metrics Collection and Exposure
MonitoringService
inserver/src/metrics/monitoring/monitoring.service.ts
to define and register custom metrics using Prometheus. Metrics are updated dynamically and include labels for additional context.MonitoringController
inserver/src/metrics/monitoring/monitoring.controller.ts
to expose a/monitoring/metrics
endpoint, which serves the collected metrics in Prometheus format.Middleware for Metrics Updates
MonitoringMiddleware
inserver/src/metrics/monitoring/monitoring.middleware.ts
to ensure metrics are updated before responding to requests for the/monitoring/metrics
endpoint.Module Integration
MonitoringModule
into the mainAppModule
andMetricsModule
to make it part of the application's dependency graph. [1] [2] [3]Screenshots (if applicable)
Checklist: