UNPKG

@hemantwasthere/monitoring-sdk

Version:

Centralized monitoring SDK for Node.js applications with Prometheus, Loki, and Grafana integration

30 lines (29 loc) 950 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MonitoringController = void 0; const metrics_1 = require("./metrics"); class MonitoringController { constructor() { this.metricsService = metrics_1.MetricsService.getInstance(); } // Express route handler for metrics endpoint async getMetrics(req, res) { try { res.setHeader("Content-Type", this.metricsService.getRegistry().contentType); const metrics = await this.metricsService.getMetrics(); res.send(metrics); } catch (error) { res.status(500).send("Error retrieving metrics"); } } // Health check endpoint async getHealth(req, res) { res.json({ status: "healthy", timestamp: new Date().toISOString(), uptime: process.uptime(), }); } } exports.MonitoringController = MonitoringController;