mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-21 13:26:41 +02:00
Phase 1: Infrastructure - Add docker/prometheus/prometheus.yml with scrape configs for all services - Add docker/grafana/provisioning for auto-configured datasources - Add docker/grafana/dashboards (system-overview, backends-docker) - Update docker-compose.macmini.yml with monitoring services: - prometheus, grafana, node-exporter, cadvisor - postgres-exporter, redis-exporter, umami - Add grafana.mana.how and analytics.mana.how to Caddyfile Phase 2: Backend Metrics - Create packages/shared-nestjs-metrics with: - MetricsModule (auto /metrics endpoint) - MetricsService (Counter, Histogram, Gauge helpers) - MetricsMiddleware (auto HTTP request tracking) Phase 3: Umami Web Analytics - Add Umami tracking scripts to all landing pages - Add Umami tracking scripts to all web apps - Create scripts/mac-mini/setup-umami-db.sh Phase 4: Admin Dashboard (ManaCore Web) - Add admin routes: /admin, /admin/users, /admin/system - Create StatCard, QuickLinks, UserTable components - Add Admin link to navigation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
/**
|
|
* @manacore/shared-nestjs-metrics
|
|
*
|
|
* Prometheus metrics module for NestJS backends.
|
|
* Automatically tracks HTTP requests, duration, and provides custom metrics.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { MetricsModule } from '@manacore/shared-nestjs-metrics';
|
|
*
|
|
* @Module({
|
|
* imports: [
|
|
* MetricsModule.register({
|
|
* prefix: 'myapp_',
|
|
* defaultLabels: { app: 'my-backend' },
|
|
* }),
|
|
* ],
|
|
* })
|
|
* export class AppModule {}
|
|
* ```
|
|
*
|
|
* The module automatically:
|
|
* - Exposes a `/metrics` endpoint for Prometheus scraping
|
|
* - Tracks HTTP request count, duration, and in-flight requests
|
|
* - Collects default Node.js metrics (CPU, memory, event loop)
|
|
*
|
|
* Custom metrics can be created via the MetricsService:
|
|
* ```typescript
|
|
* @Injectable()
|
|
* export class MyService {
|
|
* private readonly aiRequestCounter: Counter;
|
|
*
|
|
* constructor(private readonly metricsService: MetricsService) {
|
|
* this.aiRequestCounter = metricsService.createCounter(
|
|
* 'ai_requests_total',
|
|
* 'Total AI requests',
|
|
* ['model']
|
|
* );
|
|
* }
|
|
*
|
|
* async processAI(model: string) {
|
|
* this.aiRequestCounter.inc({ model });
|
|
* // ... process
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
|
|
// Module
|
|
export { MetricsModule, MetricsModuleOptions } from './metrics.module';
|
|
|
|
// Service
|
|
export { MetricsService, MetricsServiceOptions } from './metrics.service';
|
|
|
|
// Middleware
|
|
export { MetricsMiddleware } from './metrics.middleware';
|
|
|
|
// Controller
|
|
export { MetricsController } from './metrics.controller';
|
|
|
|
// Re-export prom-client types for convenience
|
|
export { Counter, Histogram, Gauge, Summary } from 'prom-client';
|