Skip to content

Implemeted health metric#274

Open
Gupta-02 wants to merge 6 commits intoYugenjr:masterfrom
Ewocs:health-metric-api
Open

Implemeted health metric#274
Gupta-02 wants to merge 6 commits intoYugenjr:masterfrom
Ewocs:health-metric-api

Conversation

@Gupta-02
Copy link
Copy Markdown
Contributor

Description

This PR implements the health and metrics endpoints requested in issue #39 to enable proper monitoring of the service in production.

Changes Made:

Added Prometheus Support

Installed prom-client package for metrics collection
Set up default Prometheus metrics collectors
Enhanced Health Service (health.service.js)

Added custom Prometheus metrics:
http_requests_total (Counter for total HTTP requests)
http_request_duration_seconds (Histogram for request latencies)
active_connections (Gauge for active connections)
memory_usage_bytes (Gauge for memory usage)
cpu_usage_percent (Gauge for CPU usage)
Added getPrometheusMetrics() function for Prometheus format output
Updated Performance Middleware (performance.middleware.js)

Modified to record metrics on each request (method, route, status code, duration)
Added New Endpoints (server.js)

GET /healthz - Lightweight health check endpoint (Kubernetes-style)
GET /metrics - Prometheus metrics endpoint for scraping
Existing Endpoints (Already Available):
GET /health/ - Basic health check with system status and dependencies
GET /health/metrics - Detailed JSON metrics
GET /health/ready - Readiness probe
GET /health/live - Liveness probe

Testing

Health Check:

Metrics:

Prometheus Configuration:

Add to your prometheus.yml:

Dependencies Added:

prom-client: For Prometheus metrics collection and formatting

Notes:

All endpoints return appropriate HTTP status codes (200 for healthy, 503 for unhealthy)
Metrics include request counts, latencies, memory usage, and CPU usage
The /healthz endpoint is a lightweight alias suitable for load balancers and Kubernetes health checks
Closes #39

@Gupta-02
Copy link
Copy Markdown
Contributor Author

@Yugenjr please merge!

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 24, 2026

Resolve conflicts

@Gupta-02
Copy link
Copy Markdown
Contributor Author

@Yugenjr resolved

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

Sorry I can't merge this. Kindly add package.lock.json in ignore file

@Gupta-02
Copy link
Copy Markdown
Contributor Author

Okay i will add

@Gupta-02
Copy link
Copy Markdown
Contributor Author

image @Yugenjr done as requested!

@Gupta-02
Copy link
Copy Markdown
Contributor Author

image Commit mssg

@Gupta-02
Copy link
Copy Markdown
Contributor Author

image

No conflicts

@Gupta-02
Copy link
Copy Markdown
Contributor Author

Please check and merge

@Gupta-02
Copy link
Copy Markdown
Contributor Author

@Yugenjr merge

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

Again and again you're including package.lock.json

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

Even after saying lot of time

@Gupta-02
Copy link
Copy Markdown
Contributor Author

See correctly the screenshot

@Gupta-02
Copy link
Copy Markdown
Contributor Author

@Yugenjr
image

Cant u see this

@Gupta-02
Copy link
Copy Markdown
Contributor Author

image

See properly the screenshot

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

image THIS IS NOT SUPPOSED TO BE HERE DONT U GET IT

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

GET /healthz - Lightweight health check endpoint (Kubernetes-style)
GET /metrics - Prometheus metrics endpoint for scraping
Existing Endpoints (Already Available):
GET /health/ - Basic health check with system status and dependencies
GET /health/metrics - Detailed JSON metrics
GET /health/ready - Readiness probe
GET /health/live - Liveness probe please send em the required ss of this as you have mentioened in your pr

@Yugenjr
Copy link
Copy Markdown
Owner

Yugenjr commented Jan 26, 2026

please share the ss of this it will be easy for me to merge i want to check also thank you

@Gupta-02
Copy link
Copy Markdown
Contributor Author

image @Yugenjr

@Gupta-02
Copy link
Copy Markdown
Contributor Author

What did u ask and what are saying now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /health and basic metrics endpoints for monitoring

2 participants